php - PhalconPHP DI : Initializers -
I am currently testing phalcon php for a project, and I have a self-implemented interface.
An example, where a class applies What I want to do is equal if there is If it is not automatically possible in Falcon PHP, then I would like to override the Thanks for your advice, Genoni FLECON \ DI \ INJECTIONEVER interface Applies. , It will inject the di automatically into that class. This is not completely true, it means that DI is injected automatically, when this service is provided, it implements the interface, D is absolutely magical Does not appear in the form because the class implements some interfaces. If there is a How does this work in a way (not technically) If your class To inject your services, you can send them to DI in your configuration or expand I think that no method is initiated during the DI, on the first call, what would be more appropriate? Yes, there is a PS: Note that you can do a few things for this to work as you want it from Falcon \ di \ InjectionInterprefer , it will inject DI into that class automatically.
Aranea \ Db \ DbAdapterAware for a class example, then in that class DBadaptor should be automatically injected. I'm doing something similar to Z Framework 2 (), where during D config, you can specify initial as follows:
'initializers' = & gt; Array ('logger' => function ($ service, $ sm) {if ($ Server version of LoggerAwareInterface) {$ logger = $ sm-> Mill ('logger'); $ service-> set Logger ($ logger);}}),
factory defaults class I was thinking and implementing it myself, what would be the right place to inject this argument? Received * in ways, or instead set * in ways? I think that no method is initiated during the initialization of the DI, but on the first call, if found * will be more suitable?
Falcon \ di \ injection (or
InjectionAwareInte RFS same way as
Falcon \ Di \ injection ). Inside
injection is a
__ go magic, which provides service to DI if the service is present. In other words, the goods are injected into DI only, and other clients search for services there.
DI or
factory default . The difference between the two is that
factory default is already configured with useful services, which you do not need though.
Falcon DI service object that represents the service and when it is resolved the first time called (if it is a shared service) Or solve every time (if it is not). You generally want all your services to be shared, otherwise it often becomes an obstacle, for example, when a non-shared database resolves the adapter, every time you call the connection Installs. |
DBADEptter :
DI :: getDefault () - & gt; GetShared ('db') ;
Comments
Post a Comment