3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\ServiceManager\Di
;
12 use Zend\Di\InstanceManager
as DiInstanceManager
;
13 use Zend\ServiceManager\ServiceLocatorInterface
;
15 class DiInstanceManagerProxy
extends DiInstanceManager
18 * @var DiInstanceManager
20 protected $diInstanceManager = null;
23 * @var ServiceLocatorInterface
25 protected $serviceLocator = null;
30 * @param DiInstanceManager $diInstanceManager
31 * @param ServiceLocatorInterface $serviceLocator
33 public function __construct(DiInstanceManager
$diInstanceManager, ServiceLocatorInterface
$serviceLocator)
35 $this->diInstanceManager
= $diInstanceManager;
36 $this->serviceLocator
= $serviceLocator;
39 $this->aliases
= &$diInstanceManager->aliases
;
40 $this->sharedInstances
= &$diInstanceManager->sharedInstances
;
41 $this->sharedInstancesWithParams
= &$diInstanceManager->sharedInstancesWithParams
;
42 $this->configurations
= &$diInstanceManager->configurations
;
43 $this->typePreferences
= &$diInstanceManager->typePreferences
;
47 * Determine if we have a shared instance by class or alias
49 * @param $classOrAlias
52 public function hasSharedInstance($classOrAlias)
54 return ($this->serviceLocator
->has($classOrAlias) ||
$this->diInstanceManager
->hasSharedInstance($classOrAlias));
60 * @param $classOrAlias
63 public function getSharedInstance($classOrAlias)
65 if ($this->serviceLocator
->has($classOrAlias)) {
66 return $this->serviceLocator
->get($classOrAlias);
69 return $this->diInstanceManager
->getSharedInstance($classOrAlias);