Exemplo n.º 1
0
 /**
  * @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);
     }
 }
 /**
  * @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;
 }
Exemplo n.º 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);
     });
 }
Exemplo n.º 4
0
 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'));
 }
Exemplo n.º 5
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']);
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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']);
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
0
 /**
  * {@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');
     });
 }
Exemplo n.º 10
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'));
 }
Exemplo n.º 11
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
     });
 }
Exemplo n.º 12
0
 public function init(\Zend\ModuleManager\ModuleManagerInterface $moduleManager)
 {
     if (\Zend\Console\Console::isConsole()) {
         return;
     }
     $eventManager = $moduleManager->getEventManager()->getSharedManager();
     $tokenListener = new TokenListener();
     $tokenListener->attachShared($eventManager);
 }
Exemplo n.º 13
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);
 }
Exemplo n.º 14
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());
 }
Exemplo n.º 15
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);
 }
Exemplo n.º 16
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));
         }
     });
 }
Exemplo n.º 17
0
 /**
  * Initializes the module.
  *
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $eventManager = $moduleManager->getEventManager();
     $eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'onLoadModulesPost'));
 }
Exemplo n.º 18
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $moduleManager
  * @return void
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $events = $moduleManager->getEventManager();
     $events->attach('loadModules.post', array($this, 'disableValidatorAnnotationForDoctrine'));
 }
Exemplo n.º 19
0
 /**
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $events = $moduleManager->getEventManager();
     $events->attach(ModuleEvent::EVENT_LOAD_MODULE, array($this, 'loadEnvironmentVariables'), -1);
 }
Exemplo n.º 20
0
 /**
  * @param ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     $eventManager = $moduleManager->getEventManager();
     $eventManager->attach(ModuleEvent::EVENT_MERGE_CONFIG, [$this, 'onMergeConfig']);
 }
 public function init(ModuleManagerInterface $manager)
 {
     // Make sure this is executed last
     $events = $manager->getEventManager();
     $events->getSharedManager()->attach('doctrine', 'loadCli.post', array($this, 'setEntityManager'), -1000);
 }
Exemplo n.º 22
0
 /**
  * Init
  *
  * @param \Zend\ModuleManager\ModuleManagerInterface $moduleManager
  */
 public function init(ModuleManagerInterface $moduleManager)
 {
     // get service manager
     $this->serviceManager = $moduleManager->getEvent()->getParam('ServiceManager');
     $moduleManager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'initPaymentListeners'));
 }
Exemplo n.º 23
0
 /**
  * {@inheritDoc}
  */
 public function init(ModuleManagerInterface $manager)
 {
     $events = $manager->getEventManager();
     $events->getSharedManager()->attach('doctrine', 'loadCli.post', [$this, 'initializeConsole']);
 }
Exemplo n.º 24
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  * @return void
  */
 public function init(ModuleManagerInterface $manager)
 {
     $manager->getEventManager()->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'setupStaticManager'));
 }
Exemplo n.º 25
0
 /**
  * Initialize workflow
  *
  * @param  ModuleManagerInterface $manager
  * @return void
  */
 public function init(ModuleManagerInterface $manager)
 {
     $manager->getEventManager()->getSharedManager()->attach('Grid\\User\\Authentication\\Service', AuthEvent::EVENT_LOGIN, array($this, 'onLogin'), 100);
 }