You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$injector->addDependenceInjector(
newDependenceInjector()
->withParamClass(TestInterface::class)
->withParamName('testA')
->referenceTo(TestA::class)
);
$injector->addDependenceInjector(
newDependenceInjector()
->withClass(MethodСlass::class)
->withParamClass(TestInterface::class)
->referenceTo(TestB::class)
);
$injector->addDependenceInjector(
newDependenceInjector()
->withClass(MethodСlass::class)
->withMethod('actionTest')
->withParamName('testA')
->referenceTo('containerID')
);
// The following code is just for example. I believe that you need to make// dependencies not by number, but by parameter name.$injector->addDependenceInjector(
newDependenceInjector()
->withClass(MethodСlass::class)
->withMethod('__construct')
->withParamPos(1)
->referenceTo('containerID')
);
// Not singleton$injector->addDependenceInjector(
newDependenceInjector()
->withParamClass(TestInterface::class)
->handler(function(ContainerInterface$container, Param$param) {
$paramClass = $param->getParamClass();
$paramName = $param->getParamName();
$paramPos = $param->getParamPos();
$methodClass = $param->getMethodClass();
$methodName = $param->getMethodName();
...
// We can return the singleton from the container.
// We can create an object and place it in a container for reuse.
})
);
$defaultDependenceInjectors = [
newDependenceInjector()->handler(function(ContainerInterface$container, Param$param) {
return$container->get($param->getParamClass());
}),
newDependenceInjector()->handler(function(ContainerInterface$container, Param$param) {
return$container->get($param->getParamClass() . '$' . $param->getParamName());
}),
];
The text was updated successfully, but these errors were encountered:
Will the Injector become too complex and confusing? Not only in terms of code, but also in terms of usage.
This can provide additional functionality to external modules. We will be able to query objects that do not live without context (for example, a database or a database table).
This can also affect performance.
I think it is necessary to impose some restrictions, such as the required parameter ParamClass or Class and create indexes when added. Thus, we will simplify calculations when looking for dependencies and the additional functionality will not affect performance.
Maybe you should think not in the direction of configuration, but in the direction of reassigning the resolveParemeter handler?
The text was updated successfully, but these errors were encountered: