/**
  * @param  ModuleManagerInterface $moduleManager
  * @throws \Exception
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     if (PHP_SAPI === 'cli') {
         return;
     }
     $rootApplicationPath = realpath(dirname('.'));
     $userConfig = $this->getUserConfig();
     if (!isset($userConfig['maintenance']['flag_file'])) {
         throw new \Exception('The \'flag_file\' parameter is missing in config/autoload/config/autoload/maintenance{,*.}{global,local}.php');
     }
     if (file_exists($rootApplicationPath . DIRECTORY_SEPARATOR . $userConfig['maintenance']['flag_file'])) {
         if (!isset($userConfig['maintenance']['status_code']) || !isset($userConfig['maintenance']['message'])) {
             throw new \Exception('Please fill all the parameters in config/autoload/config/autoload/maintenance{,*.}{global,local}.php');
         }
         $moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULE, function (ModuleEvent $moduleEvent) {
             $moduleEvent->stopPropagation(true);
         }, PHP_INT_MAX);
         $moduleManager->getEventManager()->getSharedManager()->attach(Application::class, MvcEvent::EVENT_BOOTSTRAP, function (MvcEvent $mvcEvent) use($userConfig) {
             $response = $mvcEvent->getResponse();
             $response->setStatusCode($userConfig['maintenance']['status_code']);
             $response->setContent($this->getResponseContent());
             $mvcEvent->stopPropagation(true);
         }, PHP_INT_MAX);
     }
 }
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     // Registering a listener at default priority, 1, which will trigger
     // after the ConfigListener merges config.
     $events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'onMergeConfig'));
 }
Beispiel #3
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  * @return void
  */
 public function init(ModuleManagerInterface $manager)
 {
     $eventManager = $manager->getEventManager();
     $eventManager->attach(ProfilerEvent::EVENT_PROFILER_INIT, function () {
         xhprof_enable(XHPROF_FLAGS_MEMORY);
     });
 }
Beispiel #4
0
 /**
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $moduleManager->loadModule('AssetManager');
     $sm = $moduleManager->getEvent()->getParam('ServiceManager');
     $serviceListener = $sm->get('ServiceListener');
     $serviceListener->addServiceManager('JQueryPluginManager', 'jquery_plugins', JQueryPluginProviderInterface::class, 'getJQueryPluginConfig');
 }
 /**
  * Ensure the UI module is loaded
  *
  * @param ModuleManagerInterface $modules
  */
 public function init(ModuleManagerInterface $modules)
 {
     $loaded = $modules->getLoadedModules();
     if (isset($loaded['ZF\\Apigility\\Admin\\Ui'])) {
         return;
     }
     $modules->loadModule('ZF\\Apigility\\Admin\\Ui');
 }
Beispiel #6
0
 /**
  * Initialize module.
  *
  * If the admin UI module is not loaded yet, load it.
  *
  * Disable the opcache as well.
  *
  * @param ModuleManagerInterface $modules
  */
 public function init(ModuleManagerInterface $modules)
 {
     $loaded = $modules->getLoadedModules(false);
     if (!isset($loaded['ZF\\Apigility\\Admin\\Ui'])) {
         $modules->loadModule('ZF\\Apigility\\Admin\\Ui');
     }
     $this->disableOpCache();
 }
 /**
  * {@inheritDoc}
  */
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     // Initialize logger collector once the profiler is initialized itself
     $events->attach('profiler_init', function (EventInterface $e) use($manager) {
         $manager->getEvent()->getParam('ServiceManager')->get('doctrine.couch_logger_collector.odm_default');
     });
 }
Beispiel #8
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  */
 public function init(ModuleManagerInterface $manager)
 {
     if (PHP_SAPI === 'cli') {
         return;
     }
     $eventManager = $manager->getEventManager();
     $eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'onLoadModulesPost'), -1100);
 }
 /**
  * @return ModuleManagerInterface
  */
 protected function getModuleManager()
 {
     if (null == $this->moduleManager) {
         $this->moduleManager = new ModuleManager([]);
         $this->moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, new ModuleResolverListener());
     }
     return $this->moduleManager;
 }
Beispiel #10
0
 /**
  * Init
  *
  * @param \Zend\ModuleManager\ModuleManagerInterface
  * @return void
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     // get the service manager
     $this->serviceLocator = $moduleManager->getEvent()->getParam('ServiceManager');
     // get the module manager
     $this->moduleManager = $moduleManager;
     $moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, [$this, 'initApplication']);
 }
Beispiel #11
0
 /**
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $moduleManager->loadModule('DoctrineModule');
     $moduleManager->loadModule('DoctrineORMModule');
     $moduleManager->loadModule('CmsDoctrine');
     $em = $moduleManager->getEventManager();
     $em->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, [$this, 'onPostLoadModules']);
 }
 /**
  * {@inheritdoc}
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     /** @var ServiceManager $serviceManager */
     $serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
     /** @var ServiceListenerInterface $serviceListener */
     $serviceListener = $serviceManager->get('ServiceListener');
     $serviceListener->addServiceManager(DataMapper\Manager\DataMapperManager::class, 'thorr_persistence_dmm', DataMapper\Manager\DataMapperManagerConfigProviderInterface::class, 'getDataMapperManagerConfig');
 }
Beispiel #13
0
 public function init(ModuleManagerInterface $moduleManager)
 {
     /** @var ServiceListener $serviceListener */
     $serviceListener = $moduleManager->getEvent()->getParam('ServiceManager')->get('ServiceListener');
     $serviceListener->addServiceManager(AuthorizationConditionPluginManager::class, 'zource_conditions', '', '');
     $serviceListener->addServiceManager(UiNavigationItemPluginManager::class, 'zource_ui_nav_items', '', '');
     $this->initializeErrorLogging();
 }
Beispiel #14
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  * @return void
  */
 public function init(ModuleManagerInterface $manager)
 {
     $this->moduleManager = $manager;
     $this->serviceLocator = $manager->getEvent()->getParam('ServiceManager');
     $shared = $manager->getEventManager()->getSharedManager();
     $shared->attach('Zend\\Stdlib\\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array(new InjectTemplateListener(), 'injectTemplate'), -85);
     $shared->attach('Zend\\Stdlib\\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($this, 'onDispatch'), 100);
 }
Beispiel #15
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  */
 public function init(ModuleManagerInterface $manager)
 {
     defined('REQUEST_MICROTIME') || define('REQUEST_MICROTIME', microtime(true));
     if (PHP_SAPI === 'cli') {
         return;
     }
     $eventManager = $manager->getEventManager();
     $eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'onLoadModulesPost'), -1100);
 }
Beispiel #16
0
 /**
  * {@inheritDoc}
  */
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     // Initialize logger collector once the profiler is initialized itself
     $events->attach('profiler_init', function () use($manager) {
         $manager->getEvent()->getParam('ServiceManager')->get('doctrine.sql_logger_collector.orm_default');
     });
     $events->getSharedManager()->attach('doctrine', 'loadCli.post', array($this, 'initializeConsole'));
 }
Beispiel #17
0
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     // Initialize logger collector once the profiler is initialized itself
     $events->attach('profiler_init', function () use($manager) {
         $manager->getEvent()->getParam('ServiceManager')->get('doctrine.sql_logger_collector.orm_another');
         // moduificare nome
     });
 }
Beispiel #18
0
 /**
  * Init
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     // delete the user's files and dirs
     $eventManager = UserEvent::getEventManager();
     $eventManager->attach(UserEvent::DELETE, function ($e) use($moduleManager) {
         // get a model instance
         $model = $moduleManager->getEvent()->getParam('ServiceManager')->get('Application\\Model\\ModelManager')->getInstance('FileManager\\Model\\FileManagerBase')->deleteUserHomeDirectory($e->getParam('object_id'));
     });
 }
Beispiel #19
0
 public function init(\Zend\ModuleManager\ModuleManagerInterface $moduleManager)
 {
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $eventManager = $moduleManager->getEventManager()->getSharedManager();
     $tokenListener = new TokenListener();
     $tokenListener->attachShared($eventManager);
 }
 /**
  * init
  *
  * Initialise the modules services.
  *
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     /**
      * @var ModuleManager $moduleManager
      * @var ServiceManager $serviceManager
      * @var ServiceListener $serviceListener
      */
     $serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
     $serviceListener = $serviceManager->get('ServiceListener');
     $serviceListener->addServiceManager('EntityServiceManager', 'entity_service_manager', EntityServiceProviderInterface::class, 'getEntityServiceConfig');
 }
Beispiel #21
0
 public function init(ModuleManagerInterface $moduleManager)
 {
     $events = $moduleManager->getEventManager();
     //$events->attach(ModuleEvent::EVENT_MERGE_CONFIG, array($this, 'onMergeConfig'));
     //$events->attach(ModuleEvent::EVENT_LOAD_MODULE, new ThemeListener());
     $events->attachAggregate(new ThemeListener());
     $sharedEvents = $events->getSharedManager();
     // VIEW MANAGER IS TRIGGERED AT 10000
     $sharedEvents->attach('Zend\\Mvc\\Application', MvcEvent::EVENT_BOOTSTRAP, array($this, 'onPostBootstrap'), 9999);
     //$sharedEvents->attachAggregate(new ThemeManager());
 }
Beispiel #22
0
 /**
  * @param ModuleManagerInterface $manager
  */
 public function init(ModuleManagerInterface $manager)
 {
     $loadModules = $manager->getModules();
     $adminModules = ['DoctrineModule', 'DoctrineORMModule', 'TwbBundle'];
     $addModules = [];
     foreach ($adminModules as $adminModule) {
         if (!in_array($adminModule, $loadModules)) {
             $addModules[] = $adminModule;
         }
     }
     $manager->setModules(array_merge($addModules, $loadModules));
 }
Beispiel #23
0
 /**
  * Init
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     // get service manager
     $this->serviceLocator = $moduleManager->getEvent()->getParam('ServiceManager');
     $moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, [$this, 'initApplication']);
     $eventManager = AclEvent::getEventManager();
     $eventManager->attach(AclEvent::DELETE_ROLE, function ($e) use($moduleManager) {
         $userModel = $moduleManager->getEvent()->getParam('ServiceManager')->get('Application\\Model\\ModelManager')->getInstance('User\\Model\\UserBase');
         // change the empty role with the default role
         $userModel->updateUsersWithEmptyRoles(AclBaseModel::DEFAULT_ROLE_MEMBER);
     }, -100);
 }
 /**
  * Delete user's membership levels +
  *
  * @param \Zend\ModuleManager\ModuleManagerInterface $moduleManager
  * @param integer $userId
  * @return void
  */
 protected function deleteUserMembershipLevels(ModuleManagerInterface $moduleManager, $userId)
 {
     $model = $moduleManager->getEvent()->getParam('ServiceManager')->get('Application\\Model\\ModelManager')->getInstance('Membership\\Model\\MembershipBase');
     // delete all user's connections
     if (null != ($connections = $model->getAllUserMembershipConnections($userId))) {
         foreach ($connections as $connection) {
             // delete the connection
             if (false === ($deleteResult = $model->deleteMembershipConnection($connection->id))) {
                 break;
             }
         }
     }
 }
Beispiel #25
0
 /**
  * Init
  *
  * @param \Zend\ModuleManager\ModuleManagerInterface $moduleManager
  * @return void
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     // get service manager
     $this->serviceLocator = $moduleManager->getEvent()->getParam('ServiceManager');
     // clear cache
     $eventManager = AclEvent::getEventManager();
     $eventManager->attach(AclEvent::DELETE_ROLE, function () {
         PageCacheUtility::clearPageCache();
     });
     // clear cache
     $eventManager = LocalizationEvent::getEventManager();
     $eventManager->attach(LocalizationEvent::UNINSTALL, function () {
         PageCacheUtility::clearPageCache();
     });
 }
Beispiel #26
0
 /**
  * {@inheritDoc}
  */
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     // Initialize logger collector once the profiler is initialized itself
     $events->attach(MvcEvent::EVENT_FINISH, function (\Zend\Mvc\MvcEvent $e) {
         $sm = $e->getApplication()->getServiceManager();
         $logger = $sm->get(LoggerInterface::class);
         $queries = $logger->getQueries();
         /** @var \Psr\Log\LoggerInterface $logger */
         $logger = $sm->get('WatsonZendLog');
         foreach ($queries as $query) {
             $logger->debug(json_encode($query));
         }
     });
 }
Beispiel #27
0
 /**
  * Init layout
  */
 protected function initLayout()
 {
     try {
         // get a custom template path resolver
         $templatePathResolver = $this->serviceLocator->get('Layout\\View\\Resolver\\TemplatePathStack');
         // replace the default template path stack resolver with one
         $aggregateResolver = $this->serviceLocator->get('Zend\\View\\Resolver\\AggregateResolver');
         $aggregateResolver->attach($templatePathResolver)->getIterator()->remove($this->serviceLocator->get('Zend\\View\\Resolver\\TemplatePathStack'));
         $layout = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Layout\\Model\\LayoutBase');
         $request = $this->serviceLocator->get('Request');
         // get a layout from cookies
         $allowSelectLayouts = (int) SettingService::getSetting('layout_select');
         $cookieLayout = isset($request->getCookie()->{self::LAYOUT_COOKIE}) && $allowSelectLayouts ? (int) $request->getCookie()->{self::LAYOUT_COOKIE} : null;
         // init a user selected layout
         if ($cookieLayout) {
             $activeLayouts = $layout->getLayoutsById($cookieLayout);
         } else {
             $activeLayouts = !empty(UserIdentityService::getCurrentUserIdentity()['layout']) && $allowSelectLayouts ? $layout->getLayoutsById(UserIdentityService::getCurrentUserIdentity()['layout']) : $layout->getDefaultActiveLayouts();
         }
         // add layouts paths for each module
         foreach ($this->moduleManager->getModules() as $module) {
             foreach ($activeLayouts as $layoutInfo) {
                 $templatePathResolver->addPath('module/' . $module . '/view/' . $layoutInfo['name']);
             }
         }
         LayoutService::setCurrentLayouts($activeLayouts);
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
     }
 }
Beispiel #28
0
 /**
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $moduleManager->loadModule('CmsCommon');
     $moduleManager->loadModule('DoctrineModule');
     spl_autoload_register(function ($class) {
         if (strpos($class, 'Doctrine\\ORM\\Mapping') === 0 || strpos($class, 'Doctrine\\ODM\\Mapping') === 0) {
             $namespaces = ['Doctrine\\ORM\\Mapping', 'Doctrine\\ODM\\Mapping'];
             $alias = str_replace($namespaces, 'CmsDoctrine\\Mapping\\Annotation', $class);
             if (class_exists($alias)) {
                 return class_alias($alias, $class);
             }
             $alias = str_replace($namespaces, 'Gedmo\\Mapping\\Annotation', $class);
             if (class_exists($alias)) {
                 return class_alias($alias, $class);
             }
         }
     });
 }
Beispiel #29
0
 /**
  * {@inheritDoc}
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     if (class_exists('ZendDeveloperTools\\Module')) {
         $moduleManager->loadModule('ZendDeveloperTools');
     }
     $moduleManager->loadModule('OcraCachedViewResolver');
     $moduleManager->loadModule('StrokerCache');
     $moduleManager->loadModule('CmsJquery');
     $sm = $moduleManager->getEvent()->getParam('ServiceManager');
     $serviceListener = $sm->get('ServiceListener');
     $serviceListener->addServiceManager('MapperManager', 'mappers', MapperPluginProviderInterface::class, 'getMapperConfig');
     $serviceListener->addServiceManager('DomainServiceManager', 'domain_services', DomainServicePluginProviderInterface::class, 'getDomainServiceConfig');
     $serviceListener->addServiceManager('SessionContainerManager', 'session_containers', ContainerPluginProviderInterface::class, 'getSessionContainerConfig');
 }
 /**
  * init
  *
  * @param \Zend\ModuleManager\ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
     $serviceListener = $serviceManager->get('ServiceListener');
     $serviceListener->addServiceManager('EntityRepositoryManager', 'entity_repository_manager', 'ArpEntityRepository\\ModuleManager\\Feature\\EntityRepositoryProviderInterface', 'getEntityRepositoryConfig');
 }