yiisoft / injector

PSR-11 compatible injector
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
43 stars 18 forks source link

Customization of identifier template #32

Closed roxblnfk closed 10 months ago

roxblnfk commented 3 years ago

I offer a more flexible option for formatting an identifier for use with a container than in #31

For the case of @mj4444ru the injector setting will be as follows:

(new Injector($container))->withIdTemplate(
    Injector::TEMPLATE_PARAM_CLASS . '$' . Injector::TEMPLATE_PARAM_NAME,
    Injector::TEMPLATE_PARAM_CLASS
);

Todo

samdark commented 3 years ago

The idea is more sophisticated but naming should be adjusted.

samdark commented 3 years ago

@mj4444ru what do you think?

mj4444ru commented 3 years ago

The idea is interesting and gives more possibilities.

In general, I believe that the container should be able to process such requests in one call, the second (third) call is needed for containers that cannot work with this format (But I'm not sure if this is correct for cascading/complex containers).

I propose to add the following logic to this functionality:

mj4444ru commented 3 years ago

InjectorDependence