Create the logout menu item.

@param MenuCollectionEvent $event The menu collection event.

@return void
540711
public function addLogoutItem(MenuCollectionEvent $event): void
    {
        $menu = $event->getMenu();

        $separator = $this->factory->createItem('separator', [
            'extras' => [
                'separator' => true,
                'translation_domain' => false,
            ],
        ]);
        $menu->addChild($separator);

        // Create logout menu item.
        $logout = $this->factory->createItem('menu_item.logout', [
            'route' => 'fos_user_security_logout',
            'extras' => [
                'icon' => 'sign-out',
                'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($logout);
    }
791988
public function onMenuConfigure(ConfigureMenuEvent $event)
    {
        if (!$this->permissionResolver->hasAccess('uicron', 'list')) {
            return;
        }

        $menu = $event->getMenu();

        $cronsMenu = $menu->getChild(MainMenuBuilder::ITEM_ADMIN);
        $cronsMenu->addChild(self::ITEM_CRONS, ['route' => 'edgar.ezuicron.list']);
    }
673552
public function onControllerSetup(Event $event)
    {
        /** @var AppController $controller */
        $controller = $event->getSubject();
        $isAdmin    = ($controller->request->getParam('prefix') === 'admin');

        $plugins = Plugin::loaded();
        foreach ($plugins as $plugin) {
            $path     = Plugin::path($plugin);
            $menuFile = ($isAdmin) ? 'admin_menu' : 'menu';
            $navConf  = $path . 'config/' . $menuFile . '.php';

            if (FS::isFile($navConf)) {
                /** @noinspection PhpIncludeInspection */
                require_once $navConf;
            }
        }
    }
981939
public static function onAfterRemove(Event $event)
    {
        $layout = $event->getTarget();
        if (!is_a($layout, 'BackBee\Site\Layout')) {
            return;
        }

        $dispatcher = $event->getDispatcher();
        if (null !== $dispatcher->getApplication()) {
            $dispatcher->getApplication()->getEntityManager()
                    ->getRepository('BackBee\Site\Layout')
                    ->removeThumbnail($layout, $dispatcher->getApplication());
        }

        $dispatcher->getApplication()->getRenderer()->removeLayout($layout);
    }
950845
public function preCreate(CreateEvent $event)
    {
        $organization = $event->getObject();
        $user = $this->tokenStorage->getToken()->getUser();

        if ($user instanceof User) {
            $organization->addAdministrator($user);
        }
    }
586086
public function handle(LogoutEvent $event)
    {
        $this->track(Settings::TYPEID_LOGOUT, $event->user->id, 10, null, $event->user->id);
    }
1363666
public function add(MenuItem $item)
    {
        $this->collection[$this->count] = $item;
        $this->names[$item->getName()]  = $this->count;

        $this->count++;

        return $this;
    }
1268457
public function add(string $menuId): void
    {
        $menu = TableRegistry::getTableLocator()->get('Menu.Menus')->get($menuId);
        $menuItem = $this->MenuItems->newEntity();
        if ($this->request->is('post')) {
            $data = $this->request->getData();
            $data['menu_id'] = $menu->id;
            $menuItem = $this->MenuItems->patchEntity($menuItem, $data);
            if ($this->MenuItems->save($menuItem)) {
                $this->Flash->success((string)__('The menu item has been saved.'));
                $this->redirect(['controller' => 'Menus', 'action' => 'view', $menu->id]);

                return;
            } else {
                $this->Flash->error((string)__('The menu item could not be saved. Please, try again.'));
            }
        }

        $parentMenuItems = $this->MenuItems
            ->find('treeList', ['spacer' => self::TREE_SPACER])
            ->where(['MenuItems.menu_id' => $menu->id]);

        $this->set(compact('menuItem', 'parentMenuItems'));
        $this->set('_serialize', ['menuItem']);
    }
990791
public function createView(ViewEvent $event)
    {
        $admin = $event->getAdmin();
        $action = $admin->getAction();
        $menuEvent = new MenuEvent($admin->getAction()->getConfiguration()->getParameter('menus'));
        $this->eventDispatcher->dispatch(Events::MENU, $menuEvent);
        $formName = '';

        // The form name is different according to the current action
        if ('edit' === $action->getName()) {
            $formName = 'entity';
        } elseif ('create' === $action->getName()) {
            $formName = 'entity';
        } elseif ('delete' === $action->getName()) {
            $formName = 'delete';
        }

        if ($this->shouldRedirect($admin, $action, $formName, $event->getRequest(), $admin->getConfiguration())) {
            $url = $this->getRedirectionUrl(
                $admin,
                $action,
                $admin->getConfiguration(),
                $event->getRequest()
            );

            $view = new RedirectView(
                $action->getName(),
                $admin->getName(),
                $action->getConfiguration(),
                $admin->getConfiguration()
            );
            $view->setUrl($url);
        } else {
            $view = $this->viewFactory->create(
                $event->getRequest(),
                $action->getName(),
                $admin->getName(),
                $admin->getConfiguration(),
                $action->getConfiguration(),
                $admin->getEntities(),
                $admin->getForms()
            );
        }
        $event->setView($view);
    }
72054
public function buildMenus(MenuEvent $event)
    {
        if (!$this->applicationConfiguration->getParameter('enable_menus')) {
            return;
        }
        $menuConfigurations = array_merge_recursive(
            $this->adminMenuConfigurations,
            $event->getMenuConfigurations()
        );
        $configurationEvent = new MenuConfigurationEvent($menuConfigurations);

        // Dispatch a pre-menu build event to allow dynamic configuration modifications
        $this
            ->eventDispatcher
            ->dispatch(Events::MENU_CONFIGURATION, $configurationEvent)
        ;
        $menuConfigurations = $configurationEvent->getMenuConfigurations();

        foreach ($menuConfigurations as $name => $menuConfiguration) {
            $this->menuFactory->create($name, $menuConfiguration);
        }
    }
64956
protected function _onMenuChanged(Kwf_Events_Event_Abstract $event, Kwf_Component_Data $menu)
    {
        parent::_onMenuChanged($event, $menu);
        $newCount = count($menu->getComponent()->getMenuData());

        if ($event instanceof Kwf_Component_Event_Page_Removed && $event->flag == Kwf_Component_Event_Page_Removed::FLAG_ROW_ADDED_REMOVED) {
            //if a row was ->delete()d it the the component is still in the component tree and returned by getMenuData()
            //so the newCount must be one less.
            //when changing the visibility it is not returned and $newCount is already correct.
            $newCount--;
        }

        if ($this->_emptyIfSingleEntry) $newCount--; //check with one less

        $previousCount = $newCount;
        if ($event instanceof Kwf_Component_Event_Page_Added) {
            $previousCount--;
        } else if ($event instanceof Kwf_Component_Event_Page_Removed) {
            $previousCount++;
        }
        if (!$previousCount && $newCount || $previousCount && !$newCount) {
            $this->fireEvent(new Kwf_Component_Event_Component_HasContentChanged(
                $this->_class, $menu
            ));
        }
    }
582804
public function postCreate(CreateEvent $event)
    {
        if (in_array(Options::USER_SELF_LOG, $event->getOptions())) {
            $this->userManager->logUser($event->getObject());
        }
    }
713022
public function handle(Logout $event)
    {
        $model = snake_case(class_basename($event->user));
        $data = [
            'ip' => request()->ip(),
            'ua' => request()->header('User-Agent'),
        ];
        $event->user->log("{$model}.logout", $data);
    }
178989
public function onKernelController(ControllerEvent $event): void
    {
        if (!$this->check($event)) {
            return;
        }

        if ($annotation = $this->getAnnotation($event)) {
            $annotation->setData($this->getAttributes($event));
            /* @var $annotation Cache */
            $response = $this->getCache($annotation->getKey($event->getRequest()->get(self::ROUTE)));
            if (null !== $response) {
                $event->setController(function () use (
                    $response
                ) {
                    return $response;
                });
            }
        }
    }
1211729
public function deleteMenuLinks(AfterScenarioScope $event) {
    if ($this->menuLinks) {
      foreach ($this->menuLinks as $menu_link) {
        $this->getCore()->entityDelete($menu_link);
      }

      $this->getCore()->clearMenuCache();
    }
  }
639083
public static function buildMenuItems( array $items = array(), $logoutUrl = null )
    {
        $_liTags = null;

        foreach ( $items as $_linkName => $_menuItem )
        {
            $_icon = null;

            if ( !is_array( $_menuItem ) )
            {
                $_liTags .= $_menuItem;
            }
            else
            {
                if ( null !== ( $_icon = Option::get( $_menuItem, 'icon' ) ) )
                {
                    $_icon = static::wrap( 'i', null, array('class' => 'icon-' . $_icon) );
                }

                $_class = $_menuItem['active'] ? 'active' : 'inactive';

                $_liTags .= <<<HTML
<li class="{$_class}"><a href="{$_menuItem['href']}">{$_icon}{$_linkName}</a></li>
HTML;
            }
        }

        if ( !empty( $logoutUrl ) )
        {
            $_token =
                ( class_exists( '\\Yii', false ) && false !== \Yii::app()->getRequest()->enableCsrfValidation ) ?
                    '?token=' . \Yii::app()->getRequest()->getCsrfToken() : null;

            $_liTags .= <<<HTML
<li class="pull-right"><a href="{$logoutUrl}{$_token}">Logout</a></li>
HTML;
        }

        return $_liTags;
    }
504458
public function preCreate(CreateEvent $event)
    {
        $badge = $event->getObject();

        if ($badge->getWorkspace()) {
            $badge->setEnabled($this->parametersSerializer->serialize()['badges']['enable_default']);
        }
    }