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 / Mvc / Service / ModuleManagerFactory.php
blob1465ac73a2c8b633dda91251b8abc52b4ffc3b8a
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\Mvc\Service;
12 use Zend\ModuleManager\Listener\DefaultListenerAggregate;
13 use Zend\ModuleManager\Listener\ListenerOptions;
14 use Zend\ModuleManager\ModuleEvent;
15 use Zend\ModuleManager\ModuleManager;
16 use Zend\ServiceManager\FactoryInterface;
17 use Zend\ServiceManager\ServiceLocatorInterface;
19 class ModuleManagerFactory implements FactoryInterface
21 /**
22 * Creates and returns the module manager
24 * Instantiates the default module listeners, providing them configuration
25 * from the "module_listener_options" key of the ApplicationConfig
26 * service. Also sets the default config glob path.
28 * Module manager is instantiated and provided with an EventManager, to which
29 * the default listener aggregate is attached. The ModuleEvent is also created
30 * and attached to the module manager.
32 * @param ServiceLocatorInterface $serviceLocator
33 * @return ModuleManager
35 public function createService(ServiceLocatorInterface $serviceLocator)
37 if (!$serviceLocator->has('ServiceListener')) {
38 $serviceLocator->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory');
41 $configuration = $serviceLocator->get('ApplicationConfig');
42 $listenerOptions = new ListenerOptions($configuration['module_listener_options']);
43 $defaultListeners = new DefaultListenerAggregate($listenerOptions);
44 $serviceListener = $serviceLocator->get('ServiceListener');
46 $serviceListener->addServiceManager(
47 $serviceLocator,
48 'service_manager',
49 'Zend\ModuleManager\Feature\ServiceProviderInterface',
50 'getServiceConfig'
52 $serviceListener->addServiceManager(
53 'ControllerLoader',
54 'controllers',
55 'Zend\ModuleManager\Feature\ControllerProviderInterface',
56 'getControllerConfig'
58 $serviceListener->addServiceManager(
59 'ControllerPluginManager',
60 'controller_plugins',
61 'Zend\ModuleManager\Feature\ControllerPluginProviderInterface',
62 'getControllerPluginConfig'
64 $serviceListener->addServiceManager(
65 'ViewHelperManager',
66 'view_helpers',
67 'Zend\ModuleManager\Feature\ViewHelperProviderInterface',
68 'getViewHelperConfig'
70 $serviceListener->addServiceManager(
71 'ValidatorManager',
72 'validators',
73 'Zend\ModuleManager\Feature\ValidatorProviderInterface',
74 'getValidatorConfig'
76 $serviceListener->addServiceManager(
77 'FilterManager',
78 'filters',
79 'Zend\ModuleManager\Feature\FilterProviderInterface',
80 'getFilterConfig'
82 $serviceListener->addServiceManager(
83 'FormElementManager',
84 'form_elements',
85 'Zend\ModuleManager\Feature\FormElementProviderInterface',
86 'getFormElementConfig'
88 $serviceListener->addServiceManager(
89 'RoutePluginManager',
90 'route_manager',
91 'Zend\ModuleManager\Feature\RouteProviderInterface',
92 'getRouteConfig'
94 $serviceListener->addServiceManager(
95 'SerializerAdapterManager',
96 'serializers',
97 'Zend\ModuleManager\Feature\SerializerProviderInterface',
98 'getSerializerConfig'
100 $serviceListener->addServiceManager(
101 'HydratorManager',
102 'hydrators',
103 'Zend\ModuleManager\Feature\HydratorProviderInterface',
104 'getHydratorConfig'
106 $serviceListener->addServiceManager(
107 'InputFilterManager',
108 'input_filters',
109 'Zend\ModuleManager\Feature\InputFilterProviderInterface',
110 'getInputFilterConfig'
113 $events = $serviceLocator->get('EventManager');
114 $events->attach($defaultListeners);
115 $events->attach($serviceListener);
117 $moduleEvent = new ModuleEvent;
118 $moduleEvent->setParam('ServiceManager', $serviceLocator);
120 $moduleManager = new ModuleManager($configuration['modules'], $events);
121 $moduleManager->setEvent($moduleEvent);
123 return $moduleManager;