Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Issue: Incorrect behavior of retrieveFromPeeringManagerFirst() in ServiceManager #3348

Closed
Deserved opened this issue Jan 4, 2013 · 0 comments

Comments

@Deserved
Copy link
Contributor

Deserved commented Jan 4, 2013

Link to open discussion: http://zend-framework-community.634137.n4.nabble.com/In-ServiceManager-for-peering-strange-behavior-td4658667.html#a4658671

Case scenario 1

$child = new ServiceManager();
$parent = $child->createScopedServiceManager();
$parent->setRetrieveFromPeeringManagerFirst(true);
$parent->setAllowOverride(true);

$child->setService("foo1", "boo2");
$parent->setService("foo1", "boo1");

//below returns "boo1", but expects "boo2"
var_dump($parent->get("foo1"));

Case scenario 2

$sm = new ServiceManager( );
$sm->setService("foo1", "boo1");
$sm2 = new ServiceManager();
$sm2->setRetrieveFromPeeringManagerFirst(true);
$sm2->setService("foo1", "boo2");
$sm2->addPeeringServiceManager($sm);

//below returns "boo2", but expects "boo1"
var_dump($sm2->get("foo1"));

The reason is that get(), firstly tries to retrieve instance from parent and than does search in peering SM.

Possible solution:
Would be change that firstly to search in peering SM and than try to get from parent $instances.

The possible headache:

SM = ServiceManager, picture that you have:

SM1 has child SM2, and both of them have retrieveFromPeeringManagerFirst() set to true.
SM2 has child SM3

SM1, SM2 and SM3 have key 'foo1'.

SM1 does not have control over SM2, but expects to have 'foo1' from SM2, but will get from SM3. It brings some headache for user over control for retrieving from peering.

weierophinney added a commit that referenced this issue Jan 14, 2013
- Trailing whitespace
weierophinney added a commit to zendframework/zend-servicemanager that referenced this issue May 15, 2015
weierophinney added a commit to zendframework/zend-servicemanager that referenced this issue May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants