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
9 namespace Zend\Test\Util
;
12 use Zend\ServiceManager\ServiceManager
;
19 protected $serviceManager;
22 * Load list of modules or application configuration
24 * @param array $configuration
26 public function __construct(array $configuration)
28 if (!isset($configuration['modules'])) {
29 $modules = $configuration;
30 $configuration = array(
31 'module_listener_options' => array(
32 'module_paths' => array(),
36 foreach ($modules as $key => $module) {
37 if (is_numeric($key)) {
38 $configuration['modules'][] = $module;
41 $configuration['modules'][] = $key;
42 $configuration['module_listener_options']['module_paths'][$key] = $module;
46 $smConfig = isset($configuration['service_manager']) ?
$configuration['service_manager'] : array();
47 $this->serviceManager
= new ServiceManager(new Service\
ServiceManagerConfig($smConfig));
48 $this->serviceManager
->setService('ApplicationConfig', $configuration);
49 $this->serviceManager
->get('ModuleManager')->loadModules();
55 * @return Zend\Mvc\Application
57 public function getApplication()
59 return $this->getServiceManager()->get('Application');
63 * Get the module manager
65 * @return Zend\ModuleManager\ModuleManager
67 public function getModuleManager()
69 return $this->getServiceManager()->get('ModuleManager');
77 public function getModule($moduleName)
79 return $this->getModuleManager()->getModule($moduleName);
83 * Get the service manager
87 public function getServiceManager()
89 return $this->serviceManager
;