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

Commit

Permalink
Merge branch 'hotfix/5752'
Browse files Browse the repository at this point in the history
Close #5752
Fixes #5535
  • Loading branch information
weierophinney committed Mar 3, 2014
2 parents 2a09993 + 5877f43 commit 1ef51f6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/Zend/ServiceManager/ServiceManager.php
Expand Up @@ -501,6 +501,14 @@ public function get($name, $usePeeringServiceManagers = true)
|| $this->canCreateFromAbstractFactory($cName, $name)
) {
$instance = $this->create(array($cName, $name));
} elseif ($isAlias && $this->canCreateFromAbstractFactory($name, $cName)) {
/*
* case of an alias leading to an abstract factory :
* 'my-alias' => 'my-abstract-defined-service'
* $name = 'my-alias'
* $cName = 'my-abstract-defined-service'
*/
$instance = $this->create(array($name, $cName));
} elseif ($usePeeringServiceManagers && !$this->retrieveFromPeeringManagerFirst) {
$instance = $this->retrieveFromPeeringManager($name);
}
Expand Down
10 changes: 10 additions & 0 deletions tests/ZendTest/ServiceManager/ServiceManagerTest.php
Expand Up @@ -240,6 +240,16 @@ public function testGetWithAlias()
$this->assertEquals('bar', $this->serviceManager->get('baz'));
}

/**
* @covers Zend\ServiceManager\ServiceManager::get
*/
public function testGetAbstractFactoryWithAlias()
{
$this->serviceManager->addAbstractFactory('ZendTest\ServiceManager\TestAsset\FooAbstractFactory');
$this->serviceManager->setAlias('foo', 'ZendTest\ServiceManager\TestAsset\FooAbstractFactory');
$this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\Foo', $this->serviceManager->get('foo'));
}

/**
* @covers Zend\ServiceManager\ServiceManager::get
*/
Expand Down

0 comments on commit 1ef51f6

Please sign in to comment.