how to DI inject another database connection to component

2 years ago

mcmatak
Member | 492
+
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

2 years ago

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

2 years ago

mcmatak
Member | 492
+
0
-

perfect thanks