Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / ServiceManager / Di / DiServiceInitializer.php
blobf3c0627c362b31171370a293c050fe176745706e
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\ServiceManager\Di;
12 use Zend\Di\Di;
13 use Zend\ServiceManager\Exception;
14 use Zend\ServiceManager\InitializerInterface;
15 use Zend\ServiceManager\ServiceLocatorInterface;
17 class DiServiceInitializer extends Di implements InitializerInterface
19 /**
20 * @var Di
22 protected $di = null;
24 /**
25 * @var DiInstanceManagerProxy
27 protected $diInstanceManagerProxy = null;
29 /**
30 * @var ServiceLocatorInterface
32 protected $serviceLocator = null;
34 /**
35 * Constructor
37 * @param \Zend\Di\Di $di
38 * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
39 * @param null|DiInstanceManagerProxy $diImProxy
41 public function __construct(Di $di, ServiceLocatorInterface $serviceLocator, DiInstanceManagerProxy $diImProxy = null)
43 $this->di = $di;
44 $this->serviceLocator = $serviceLocator;
45 $this->diInstanceManagerProxy = ($diImProxy) ?: new DiInstanceManagerProxy($di->instanceManager(), $serviceLocator);
48 /**
49 * Initialize
51 * @param $instance
52 * @param ServiceLocatorInterface $serviceLocator
53 * @throws \Exception
55 public function initialize($instance, ServiceLocatorInterface $serviceLocator)
57 $instanceManager = $this->di->instanceManager;
58 $this->di->instanceManager = $this->diInstanceManagerProxy;
59 try {
60 $this->di->injectDependencies($instance);
61 $this->di->instanceManager = $instanceManager;
62 } catch (\Exception $e) {
63 $this->di->instanceManager = $instanceManager;
64 throw $e;