/** * Initializes provided context. * * @param Context $context */ public function initializeContext(Context $context) { if (!$context instanceof ServiceManagerAwareInterface) { return; } if (!file_exists($this->file)) { throw new \LogicException(sprintf('The file %s was not found', $this->file)); } // We _should_ always be in the root of a zf2 project when executing this $config = (include $this->file); $serviceManager = new ServiceManager(new ServiceManagerConfig($config)); $serviceManager->setService('ApplicationConfig', $config); /* @var $moduleManager \Zend\ModuleManager\ModuleManager */ $moduleManager = $serviceManager->get('ModuleManager'); $moduleManager->loadModules(); $context->setServiceManager($serviceManager); }