Locator injection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Locator injection

Eugene Poleacov
This post has NOT been accepted by the mailing list yet.
Hello, everyone.
Could somebody answer me how to inject locator into his items by Di configuration?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Locator injection

dmitrybelyakov
This post has NOT been accepted by the mailing list yet.
You can hint that in your constructor signature:

public function __construct(\Zend\Di\Locator $locator)

or if you don't use a constructor have a setter:

public function setLocator(\Zend\Di\Locator $locator)

then each time you grab your object from di it will be injected with locator.
Reply | Threaded
Open this post in threaded view
|

Re: Locator injection

Eugene Poleacov
Yeah, you right.
Is simple as always in ZF. :)

Thanks.