本文整理汇总了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);
}
}
示例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;
}
}
}