-
-
Notifications
You must be signed in to change notification settings - Fork 324
Support for DI\link and DI\object in arrays #190
Copy link
Copy link
Closed
Labels
Description
Consider following two examples:
<?php
return [
\MyProject\Dispatcher::class => DI\object()->constructor(
DI\link(\MyProject\Router::class),
[
DI\link(\MyProject\Controllers\AuthController::class),
DI\link(\MyProject\Controllers\OtherController::class)
]),
];
and something equivalent
<?php
return [
\MyProject\Dispatcher::class => DI\object()->constructor(
DI\link(\MyProject\Router::class),
DI\link('controllers')),
'controllers' => [
DI\link(\MyProject\Controllers\AuthController::class),
DI\link(\MyProject\Controllers\OtherController::class)
],
];
None of these seem to work - when I instantiate Dispatcher class, I end up having an array like this:
array(1) {
[0]=>
object(DI\Definition\EntryReference)#27 (1) {
["name":"DI\Definition\EntryReference":private]=>
string(37) "MyProject\Controllers\AuthController"
},
[1]=>
object(DI\Definition\EntryReference)#28 (1) {
["name":"DI\Definition\EntryReference":private]=>
string(37) "MyProject\Controllers\OtherController"
}
}
To get things going, I had to introduce ControllerRepostory, which emulates such through constructor with boilerplate variables:
class ControllerRepository
{
private $controllers = [];
public function __construct(
\MyProject\Controllers\AuthController $whatever,
\MyProject\Controllers\OtherController $whatever2)
{
$this->controllers = func_get_args();
}
public function getControllers()
{
return $this->controllers;
}
}
Although I managed to solve my problem, it still has a "missing feature" ring to it.
Reactions are currently unavailable