当前位置: 首页>>代码示例>>PHP>>正文


PHP Mvc\ModuleRouteListener类代码示例

本文整理汇总了PHP中Zend\Mvc\ModuleRouteListener的典型用法代码示例。如果您正苦于以下问题:PHP ModuleRouteListener类的具体用法?PHP ModuleRouteListener怎么用?PHP ModuleRouteListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ModuleRouteListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onBootstrap

 public function onBootstrap($e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH, array($this, 'rotateXPoweredByHeader'));
 }
开发者ID:vrkansagara,项目名称:zf-web,代码行数:7,代码来源:Module.php

示例2: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->setPhpSettings($e);
 }
开发者ID:highestgoodlikewater,项目名称:php-kanban,代码行数:7,代码来源:Module.php

示例3: onBootstrap

 public function onBootstrap($e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:agerecompany,项目名称:zfc-block,代码行数:7,代码来源:Module.php

示例4: onBootstrap

 /**
  * {@inheritdoc}
  */
 public function onBootstrap(EventInterface $e)
 {
     /** @var \Zend\Mvc\MvcEvent $e */
     /** @var \Zend\Mvc\Application $application */
     $application = $e->getApplication();
     /** @var \Zend\EventManager\EventManager $events */
     $events = $application->getEventManager();
     /** @var \Zend\EventManager\SharedEventManager $sharedEvents */
     $sharedEvents = $events->getSharedManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($events);
     // Override Zend\Mvc\View\Http\InjectTemplateListener
     // to process templates by Vendor/Module
     $injectTemplateListener = new InjectTemplateListener();
     $sharedEvents->attach('Zend\\Stdlib\\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$injectTemplateListener, 'injectTemplate'], -89);
     $response = $e->getResponse();
     if ($response instanceof \Zend\Http\Response) {
         $headers = $response->getHeaders();
         if ($headers) {
             $headers->addHeaderLine('Cache-Control', 'no-cache, no-store, must-revalidate');
             $headers->addHeaderLine('Pragma', 'no-cache');
             $headers->addHeaderLine('Expires', '1970-01-01');
         }
     }
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:28,代码来源:Module.php

示例5: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Add translation
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $setLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     } else {
         $setLang = '';
     }
     $translator->setLocale(\Locale::acceptFromHttp($setLang))->setFallbackLocale('en_US');
     // Add ACL information to the Navigation view helper
     $sm = $e->getApplication()->getServiceManager();
     $authorize = $sm->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) use($sm) {
         if ($e->getParam('exception')) {
             $sm->get('Zend\\Log\\Logger')->crit($e->getParam('exception'));
         }
     });
 }
开发者ID:riceri,项目名称:MvitInvoice,代码行数:27,代码来源:Module.php

示例6: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Listeners to ensure that we always send back JSON.
     // If we set a 404 in the ViewModel, then the RouteNotFoundStrategy will add it's own
     // fields to the ViewModel, so detect a 404 first and respond to it
     $eventManager->getSharedManager()->attach('Zend\\Stdlib\\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($this, 'detect404'), -89);
     // Ensure we always render JSON
     $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'ensureJsonModel'), 999);
     // Turn errors into JSON
     // $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'renderError'));
     //*********Session
     $sm = $e->getApplication()->getServiceManager();
     $config = $sm->get('session_config');
     $storage = null;
     if ($sm->has('session_storage', false)) {
         $storage = $sm->get('session_storage');
     }
     $saveHandler = null;
     if ($sm->has('session_save_handler', false)) {
         $saveHandler = $sm->get('session_save_handler');
     }
     $sessionManager = new SessionManager($config, $storage, $saveHandler);
     Container::setDefaultManager($sessionManager);
     //$sessionManager->start();
 }
开发者ID:ledsinclouds,项目名称:RestServerDemo,代码行数:28,代码来源:Module.php

示例7: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $eventManager = $app->getEventManager();
     $locator = $app->getServiceManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->initFirePHP();
     $this->initAuthentication();
     // 微软这个流氓,低于IE10版本一下的IE浏览器都需要使用text/html格式的Response,否则json在浏览器中会提示下载
     $eventManager->attach(MvcEvent::EVENT_RENDER, function ($event) {
         $objResponse = $event->getResponse();
         if (method_exists($objResponse, 'getHeaders')) {
             $objHeaders = $objResponse->getHeaders();
             $contentType = $objHeaders->get('Content-Type');
             if ($contentType) {
                 $contentType = $contentType->getFieldValue();
                 if (strpos($contentType, 'application/json') !== false) {
                     $objHeaders->addHeaderLine('Content-Type', 'text/html;charset=utf-8');
                 }
             } else {
                 $objHeaders->addHeaderLine('Content-Type', 'text/html;charset=utf-8');
             }
         }
     }, -10000);
     // 错误提示的时候,执行特殊的layout
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, function (MvcEvent $event) {
         $viewModel = $event->getViewModel();
         $viewModel->setTemplate('layout/error');
     }, -200);
 }
开发者ID:im286er,项目名称:ent,代码行数:31,代码来源:Module.php

示例8: onBootstrap

 public function onBootstrap($e)
 {
     \Zend\Validator\AbstractValidator::setDefaultTranslator($e->getApplication()->getServiceManager()->get('translator'));
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:khusamov,项目名称:leading,代码行数:7,代码来源:Module.php

示例9: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->attach(MvcEvent::EVENT_ROUTE, [$this, 'onViewHelper']);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $routeMatch = $e->getRouteMatch();
         $apartmentId = $routeMatch->getParam('apartment_id', 0);
         // get the apartment ID
         if (method_exists($controller, 'setApartmentID')) {
             $serviceManager = $e->getApplication()->getServiceManager();
             $dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
             $apartmentExistValidator = new RecordExists(['adapter' => $dbAdapter, 'table' => DbTables::TBL_APARTMENTS, 'field' => 'id']);
             if (!$apartmentExistValidator->isValid($apartmentId) && $apartmentId != 0) {
                 $url = $e->getRouter()->assemble(array('controller' => 'apartment', 'action' => 'search'), ['name' => 'apartments']);
                 $response = $e->getResponse();
                 $response->getHeaders()->addHeaderLine('Location', $url);
                 $response->setStatusCode(302);
                 $response->sendHeaders();
                 return $response;
             }
             $controller->setApartmentID($apartmentId);
         }
     }, 100);
 }
开发者ID:arbi,项目名称:MyCode,代码行数:27,代码来源:Module.php

示例10: onBootstrap

 public function onBootstrap($e)
 {
     $session = $e->getApplication()->getServiceManager()->get('session');
     if (isset($session->lang)) {
         $translator = $e->getApplication()->getServiceManager()->get('translator');
         $translator->setLocale($session->lang);
         $viewModel = $e->getViewModel();
         $viewModel->lang = str_replace('_', '-', $session->lang);
     }
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->attach('route', function ($e) {
         $lang = $e->getRouteMatch()->getParam('lang');
         // If there is no lang parameter in the route, nothing to do
         if (empty($lang)) {
             return;
         }
         $services = $e->getApplication()->getServiceManager();
         // If the session language is the same, nothing to do
         $session = $services->get('session');
         if (isset($session->lang) && $session->lang == $lang) {
             return;
         }
         $viewModel = $e->getViewModel();
         $translator = $services->get('translator');
         $viewModel->lang = $lang;
         $lang = str_replace('-', '_', $lang);
         $translator->setLocale($lang);
         $session->lang = $lang;
     }, -10);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:bmatmentel,项目名称:zf2-propel,代码行数:32,代码来源:Module.php

示例11: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     AnnotationRegistry::registerAutoloadNamespace('TgBotApi\\Model\\Annotation');
 }
开发者ID:BreyndotEchse,项目名称:mtg-bot,代码行数:7,代码来源:Module.php

示例12: onBootstrap

 public function onBootstrap($e)
 {
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         if (isset($config['module_layouts'][$moduleNamespace])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]);
         }
     }, 100);
     $session = new Container('base');
     if (!$session->offsetExists('language')) {
         if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "es") {
             $session->offsetSet('language', "es_ES");
         } elseif (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "en") {
             $session->offsetSet('language', "en_US");
         }
     }
     $e->getApplication()->getServiceManager()->get('translator')->setLocale($session->offsetGet('language'));
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:tineo,项目名称:webapoyopublicitario,代码行数:25,代码来源:Module.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $event)
 {
     Json::$useBuiltinEncoderDecoder = true;
     $eventManager = $event->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
 }
开发者ID:aiolos,项目名称:haltes,代码行数:7,代码来源:Module.php

示例14: onBootstrap

 /**
  * @param MvcEvent $event
  */
 public function onBootstrap(MvcEvent $event)
 {
     $eventManager = $event->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $app = $event->getApplication();
     $serviceManager = $app->getServiceManager();
     // Set the Query Profiler
     $profiler = new DoplioFirePhpProfiler();
     $capsule = new Capsule();
     $config = $serviceManager->get('config')['database'];
     foreach ($config as $connName => $dbConfig) {
         $capsule->addConnection($dbConfig, $connName);
         if (isset($dbConfig['profiler']) && $dbConfig['profiler'] === TRUE) {
             $profiler->enable();
         }
     }
     //        $capsule->setCacheManager();
     $capsule->bootEloquent();
     $serviceManager->setService('Doplio', $capsule);
     $serviceManager->setService('DoplioFirePhpProfiler', $profiler);
     $eventManager->attach(MvcEvent::EVENT_FINISH, function () use($capsule, $config, $profiler) {
         if ($profiler->isDisabled()) {
             return;
         }
         foreach ($config as $connectionName => $notUsed) {
             $connection = $capsule->getConnection($connectionName);
             foreach ($connection->getQueryLog() as $query) {
                 $profiler->addQuery($query, $connectionName);
             }
         }
         $profiler->showTables();
     });
 }
开发者ID:middleout,项目名称:doplio-zf2,代码行数:37,代码来源:Module.php

示例15: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     /*
             $eventManager        = $e->getApplication()->getEventManager();
             $moduleRouteListener = new ModuleRouteListener();
             $moduleRouteListener->attach($eventManager);
     
     $this->initSession(array(
     'remember_me_seconds' => 180,
     'use_cookies' => true,
     'cookie_httponly' => true,
     ));
     */
     $eventManager = $e->getApplication()->getEventManager();
     $eventManager->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
         $controller = $e->getTarget();
         $controllerClass = get_class($controller);
         $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
         $config = $e->getApplication()->getServiceManager()->get('config');
         //echo '<pre>'; print_r($config);exit;
         if (isset($config['module_layouts'][$moduleNamespace])) {
             $controller->layout($config['module_layouts'][$moduleNamespace]);
         }
     }, 100);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->initSession(array('remember_me_seconds' => 180, 'use_cookies' => true, 'cookie_httponly' => true));
 }
开发者ID:bladehr8,项目名称:bowhunter2015,代码行数:28,代码来源:Module.php


注:本文中的Zend\Mvc\ModuleRouteListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。