當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EventManager\StaticEventManager類代碼示例

本文整理匯總了PHP中Zend\EventManager\StaticEventManager的典型用法代碼示例。如果您正苦於以下問題:PHP StaticEventManager類的具體用法?PHP StaticEventManager怎麽用?PHP StaticEventManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了StaticEventManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: attachConfigEvents

 /**
  * Attach scripts and links to the view helpers based on the configuration file.
  * @todo Handle priority
  * @todo Add extended specification for scripts and links
  */
 protected function attachConfigEvents()
 {
     $config = $this->serviceLocator->get('Configuration');
     if (isset($config['dots']['view']['events']) && is_array($config['dots']['view']['events'])) {
         foreach ($config['dots']['view']['events'] as $name => $options) {
             if (!empty($options)) {
                 StaticEventManager::getInstance()->attach('dots', $name, function (Event $event) use($options) {
                     $view = $event->getTarget();
                     if (isset($options['scripts']) && is_array($options['scripts'])) {
                         $scripts = array_filter($options['scripts'], function ($script) {
                             return $script != null;
                         });
                         foreach ($scripts as $script) {
                             $view->plugin('headScript')->appendFile($script);
                         }
                     }
                     if (isset($options['links']) && is_array($options['links'])) {
                         $links = array_filter($options['links'], function ($link) {
                             return $link != null;
                         });
                         foreach ($links as $script) {
                             $view->plugin('headLink')->appendStylesheet($script);
                         }
                     }
                 }, 200);
             }
         }
     }
 }
開發者ID:Ellipizle,項目名稱:dotscms,代碼行數:34,代碼來源:Listener.php

示例2: __construct

 public function __construct()
 {
     $event = $this->getEvent();
     $this->viewModel = $event->getViewModel();
     $sharedEvents = StaticEventManager::getInstance();
     $sharedEvents->attach('Zend\\Mvc\\Controller\\AbstractActionController', MvcEvent::EVENT_DISPATCH, function (Event $event) {
         // get view model for layout
         $view = $event->getViewModel();
         // assign locales information
         $sm = $this->getServiceLocator();
         $config = $sm->get('Configuration');
         $view->setVariable('locale', $sm->get('translator')->getLocale());
         $view->setVariable('locales', $config['locales']['list']);
         // assign flashmessanger messages
         $messages = $this->flashmessenger()->getSuccessMessages();
         $view->setVariable('messages', $messages);
         $info = $this->flashmessenger()->getInfoMessages();
         $view->setVariable('info', $info);
         $warnings = $this->flashmessenger()->getMessages();
         $view->setVariable('warnings', $warnings);
         $errors = $this->flashmessenger()->getErrorMessages();
         $view->setVariable('errors', $errors);
         // assign variables to action view
         $this->viewModel->setVariables($view->getVariables());
     });
 }
開發者ID:evolic,項目名稱:loculus,代碼行數:26,代碼來源:DefaultController.php

示例3: init

 /**
  * Initialize the module
  *
  * @param ModuleManager $m Module manager
  *
  * @return void
  */
 public function init(ModuleManager $m)
 {
     if (!Console::isConsole()) {
         $em = StaticEventManager::getInstance();
         $em->attach('Zend\\Mvc\\Application', 'bootstrap', [$this, 'registerBaseUrl'], 100000);
     }
 }
開發者ID:samuli,項目名稱:vufind-ere,代碼行數:14,代碼來源:Module.php

示例4: init

 public function init()
 {
     // Attach Event to EventManager
     $events = StaticEventManager::getInstance();
     // Add event of authentication before dispatch
     $events->attach('Zend\\View\\View', ViewEvent::EVENT_RENDERER_POST, array($this, 'addPiwikCode'), 110);
 }
開發者ID:VaporFan,項目名稱:piwik,代碼行數:7,代碼來源:Module.php

示例5: setEventCollection

 public static function setEventCollection(EventManagerInterface $events = null)
 {
     parent::setEventCollection($events);
     $sharedManager = StaticEventManager::getInstance();
     static::$events->setSharedManager($sharedManager);
     static::$events->setIdentifiers(array(__CLASS__, get_called_class(), 'dots'));
 }
開發者ID:Ellipizle,項目名稱:dotscms,代碼行數:7,代碼來源:GlobalEventManager.php

示例6: init

 public function init(Manager $moduleManager)
 {
     $events = StaticEventManager::getInstance();
     # post configuration merge
     $events->attach('Zend\\Module\\Manager', 'loadModules.post', array($this, 'postModulesLoadsListener'), 8);
     # pre bootstrap
     $events->attach('bootstrap', 'bootstrap', array($this, 'preBootstrapListener'), 20);
 }
開發者ID:widmogrod,項目名稱:zf2-facebook-module,代碼行數:8,代碼來源:Module.php

示例7: setUp

 public function setUp()
 {
     StaticEventManager::resetInstance();
     if (isset($this->message)) {
         unset($this->message);
     }
     $this->events = new EventManager();
 }
開發者ID:robertodormepoco,項目名稱:zf2,代碼行數:8,代碼來源:EventManagerTest.php

示例8: _afterLogin

 private function _afterLogin($e)
 {
     $em = \Zend\EventManager\StaticEventManager::getInstance();
     $em->attach('ZfcUser\\Authentication\\Adapter\\AdapterChain', 'authenticate.success', function ($e) {
         $userId = $e->getIdentity();
         $this->_logService->log(LogService::NOTICE, "Connexion de l'utilisateur: {$userId}", LogService::USER);
         $this->_userTable->updateLastConnection($userId);
     });
 }
開發者ID:antarus,項目名稱:mystra-pve,代碼行數:9,代碼來源:Module.php

示例9: setUp

 public function setUp()
 {
     StaticEventManager::resetInstance();
     $this->controller = new TestAsset\SampleController();
     $this->request = new Request();
     $this->response = null;
     $this->routeMatch = new RouteMatch(array('controller' => 'controller-sample'));
     $this->event = new MvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
 }
開發者ID:razvansividra,項目名稱:pnlzf2-1,代碼行數:11,代碼來源:ActionControllerTest.php

示例10: setUp

 public function setUp()
 {
     StaticEventManager::resetInstance();
     $this->controller = new IndexController();
     $this->request = new Request();
     $this->response = null;
     $this->routeMatch = new RouteMatch(array('controller' => 'php-unit-controller-index'));
     $this->event = new MvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
 }
開發者ID:jordiwes,項目名稱:zf2.unlikelysource.org,代碼行數:11,代碼來源:IndexControllerTest.php

示例11: initializeView

 public function initializeView(Event $e)
 {
     $app = $e->getParam('application');
     $locator = $app->getLocator();
     $config = $e->getParam('modules')->getMergedConfig();
     $view = $this->getView($app, $config);
     $viewListener = $this->getViewListener($view, $config);
     $app->events()->attachAggregate($viewListener);
     $events = StaticEventManager::getInstance();
     $viewListener->registerStaticListeners($events, $locator);
 }
開發者ID:bb-drummer,項目名稱:Zcmf,代碼行數:11,代碼來源:Module.php

示例12: onBootstrap

 public function onBootstrap($e)
 {
     $app = $e->getTarget();
     $this->sm = $app->getServiceManager();
     StaticEventManager::getInstance()->attach('ZF\\Rest\\RestController', 'getList.post', function ($e) {
         $halCollection = $e->getParam('collection');
         $parameters = $e->getTarget()->queryParams();
         unset($parameters['page']);
         $halCollection->setCollectionRouteOptions(array('query' => $parameters));
     });
 }
開發者ID:kapitchi,項目名稱:kap-apigility,代碼行數:11,代碼來源:Module.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $em = $e->getApplication()->getServiceManager()->get('Doctrine\\ORM\\EntityManager');
     $platform = $em->getConnection()->getDatabasePlatform();
     $platform->registerDoctrineTypeMapping('enum', 'string');
     $this->initializeSessions($e);
     $sharedEventManager = StaticEventManager::getInstance();
     $sharedEventManager->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, array($this, 'onLoad'), 200);
 }
開發者ID:kristjanAnd,項目名稱:SimpleIV,代碼行數:12,代碼來源:Module.php

示例14: _after

 public function _after(\Codeception\TestCase $test)
 {
     $_SESSION = array();
     $_GET = array();
     $_POST = array();
     $_COOKIE = array();
     // reset singleton
     StaticEventManager::resetInstance();
     Placeholder\Registry::unsetRegistry();
     $this->queries = 0;
     $this->time = 0;
 }
開發者ID:NaszvadiG,項目名稱:ImageCMS,代碼行數:12,代碼來源:ZF2.php

示例15: defineEventHandlers

 public function defineEventHandlers()
 {
     $events = StaticEventManager::getInstance();
     $view = $this->di->get('view');
     $events->attach('Zf2\\Mvc\\FrontController', 'dispatch.post', function ($e) use($view) {
         $response = $e->getParam('response');
         if ($response->getHeaders()->getStatusCode() != 302) {
             $content = $view->render($e->getParam('request'), $e->getParam('__RESULT__'));
             $response->setContent($content);
         }
         return $response;
     });
 }
開發者ID:GeeH,項目名稱:zf2-sandbox,代碼行數:13,代碼來源:Bootstrap.php


注:本文中的Zend\EventManager\StaticEventManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。