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

Commit

Permalink
Forward #3813
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Schindler committed Feb 19, 2013
2 parents 6a70028 + 6f1a330 commit 6ff6d21
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
6 changes: 3 additions & 3 deletions library/Zend/ServiceManager/ServiceManager.php
Expand Up @@ -445,7 +445,7 @@ public function get($name, $usePeeringServiceManagers = true)
} }


// Still no instance? raise an exception // Still no instance? raise an exception
if (!$instance && !is_array($instance)) { if ($instance === null && !is_array($instance)) {
if ($isAlias) { if ($isAlias) {
throw new Exception\ServiceNotFoundException(sprintf( throw new Exception\ServiceNotFoundException(sprintf(
'An alias "%s" was requested but no service could be found.', 'An alias "%s" was requested but no service could be found.',
Expand Down Expand Up @@ -494,11 +494,11 @@ public function create($name)
$instance = $this->createFromFactory($cName, $rName); $instance = $this->createFromFactory($cName, $rName);
} }


if (!$instance && isset($this->invokableClasses[$cName])) { if ($instance === false && isset($this->invokableClasses[$cName])) {
$instance = $this->createFromInvokable($cName, $rName); $instance = $this->createFromInvokable($cName, $rName);
} }


if (!$instance && $this->canCreateFromAbstractFactory($cName, $rName)) { if ($instance === false && $this->canCreateFromAbstractFactory($cName, $rName)) {
$instance = $this->createFromAbstractFactory($cName, $rName); $instance = $this->createFromAbstractFactory($cName, $rName);
} }


Expand Down
12 changes: 12 additions & 0 deletions tests/ZendTest/ServiceManager/ServiceManagerTest.php
Expand Up @@ -560,6 +560,18 @@ public function testShouldRaiseExceptionIfInitializerClassIsNotAnInitializerInte
$result = $this->serviceManager->addInitializer(get_class($this)); $result = $this->serviceManager->addInitializer(get_class($this));
} }


public function testGetGlobIteratorServiceWorksProperly()
{
$config = new Config(array(
'invokables' => array(
'foo' => 'ZendTest\ServiceManager\TestAsset\GlobIteratorService',
),
));
$serviceManager = new ServiceManager($config);
$foo = $serviceManager->get('foo');
$this->assertInstanceOf('ZendTest\ServiceManager\TestAsset\GlobIteratorService', $foo);
}

public function duplicateService() public function duplicateService()
{ {
$self = $this; $self = $this;
Expand Down
19 changes: 19 additions & 0 deletions tests/ZendTest/ServiceManager/TestAsset/GlobIteratorService.php
@@ -0,0 +1,19 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ServiceManager
*/

namespace ZendTest\ServiceManager\TestAsset;

class GlobIteratorService extends \GlobIterator
{
public function __construct()
{
}
}

0 comments on commit 6ff6d21

Please sign in to comment.