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


PHP FilterControllerEvent::getDispatcher方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpKernel\Event\FilterControllerEvent::getDispatcher方法的典型用法代碼示例。如果您正苦於以下問題:PHP FilterControllerEvent::getDispatcher方法的具體用法?PHP FilterControllerEvent::getDispatcher怎麽用?PHP FilterControllerEvent::getDispatcher使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpKernel\Event\FilterControllerEvent的用法示例。


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

示例1: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     // admin menu will be rendered only when HttpKernelInterface::MASTER_REQUEST
     if ($event->getRequestType() == HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     if (!$this->container->get('session')->has('admin/menu')) {
         $builder = new AdminMenuBuilder();
         $builder->add(new AdminMenuItem(['id' => 'dashboard', 'class' => 'dashboard', 'name' => $this->translator->trans('Dashboard'), 'path' => '[menu][dashboard]', 'sort_order' => 10]));
         $builder->add(new AdminMenuItem(['id' => 'catalog', 'class' => 'catalog', 'name' => $this->translator->trans('Catalog'), 'path' => '[menu][catalog]', 'sort_order' => 20]));
         $builder->add(new AdminMenuItem(['id' => 'promotions', 'class' => 'promotions', 'name' => $this->translator->trans('Promotions'), 'path' => '[menu][promotions]', 'sort_order' => 30]));
         $builder->add(new AdminMenuItem(['id' => 'sales', 'class' => 'sales', 'name' => $this->translator->trans('Sales'), 'path' => '[menu][sales]', 'sort_order' => 40]));
         $builder->add(new AdminMenuItem(['id' => 'reports', 'class' => 'reports', 'name' => $this->translator->trans('Reports'), 'path' => '[menu][reports]', 'sort_order' => 50]));
         $builder->add(new AdminMenuItem(['id' => 'crm', 'class' => 'crm', 'name' => $this->translator->trans('CRM'), 'link' => '', 'path' => '[menu][crm]', 'sort_order' => 60]));
         $builder->add(new AdminMenuItem(['id' => 'cms', 'class' => 'cms', 'name' => $this->translator->trans('CMS'), 'path' => '[menu][cms]', 'sort_order' => 70]));
         $builder->add(new AdminMenuItem(['id' => 'layout', 'class' => 'layout', 'name' => $this->translator->trans('Layout settings'), 'path' => '[menu][layout]', 'sort_order' => 80]));
         $builder->add(new AdminMenuItem(['id' => 'integration', 'class' => 'integration', 'name' => $this->translator->trans('Integration'), 'path' => '[menu][integration]', 'sort_order' => 90]));
         $builder->add(new AdminMenuItem(['id' => 'configuration', 'class' => 'configuration', 'name' => $this->translator->trans('Configuration'), 'link' => '', 'path' => '[menu][configuration]', 'sort_order' => 100]));
         $builder->add(new AdminMenuItem(['id' => 'localization', 'class' => 'localization', 'name' => $this->translator->trans('Localization'), 'path' => '[menu][configuration][localization]', 'sort_order' => 10]));
         $builder->add(new AdminMenuItem(['id' => 'store_management', 'class' => 'store_management', 'name' => $this->translator->trans('Store management'), 'path' => '[menu][configuration][store_management]', 'sort_order' => 20]));
         $builder->add(new AdminMenuItem(['id' => 'user_management', 'name' => $this->translator->trans('User management'), 'path' => '[menu][configuration][user_management]', 'sort_order' => 30]));
         $adminMenuEvent = new AdminMenuInitEvent($builder);
         $event->getDispatcher()->dispatch(AdminMenuInitEvent::ADMIN_MENU_INIT_EVENT, $adminMenuEvent);
         $menu = $adminMenuEvent->getBuilder()->getMenu();
         $this->container->get('session')->set('admin/menu', $menu);
     }
 }
開發者ID:jmarceli,項目名稱:WellCommerce,代碼行數:27,代碼來源:AdminMenuListener.php

示例2: controllerListener

 public function controllerListener(FilterControllerEvent $event)
 {
     static $possibleMatches = ['product_id' => 'product', 'category_id' => 'category', 'content_id' => 'content', 'folder_id' => 'folder'];
     $request = $event->getRequest();
     // Try to find a direct match. A view is defined for the object.
     foreach ($possibleMatches as $parameter => $objectType) {
         if (null !== ($objectId = $request->query->get($parameter))) {
             $findEvent = new FindViewEvent($objectId, $objectType);
             $event->getDispatcher()->dispatch('view.find', $findEvent);
             if ($findEvent->hasView()) {
                 $event->getRequest()->query->set('view', $findEvent->getView());
             }
             return;
         }
     }
 }
開發者ID:roadster31,項目名稱:thelia-modules-View,代碼行數:16,代碼來源:ControllerListener.php


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