how to DI inject another database connection to component

3 years ago

mcmatak
Member | 499
+
0
-

how to do something like this?

in config.neon?

		- App\Components\IUserControlFactory(@database.default.context)

this would not work

public function createComponentUser($name)
       {
           $factory = $this->getContext()->getByType(IUserControlFactory::class);

in this case the $factory will by type of Nette\Database\Context not UserControl

3 years ago

David Matějka
Moderator | 5988
+
+1
-
-
	implement: App\Components\IUserControlFactory
	arguments: [@database.default.context]

3 years ago

mcmatak
Member | 499
+
0
-

perfect thanks