public function prepareContentMenu(Event $event, OrmManager $ormManager)
 {
     $locale = $event->getArgument('locale');
     $menu = $event->getArgument('menu');
     $models = $ormManager->getModels();
     foreach ($models as $model) {
         $meta = $model->getMeta();
         $option = $meta->getOption('scaffold.expose');
         if (!$option) {
             continue;
         }
         $menuItem = new MenuItem();
         $title = $meta->getOption('scaffold.title');
         if ($title) {
             $menuItem->setTranslation($title);
         } else {
             $menuItem->setLabel($meta->getName());
         }
         $menuItem->setRoute('system.orm.scaffold.index', array('locale' => $locale, 'model' => $meta->getName()));
         $menu->addMenuItem($menuItem);
     }
 }
 /**
  * Action to add the CMS menus to the taskbar
  * @param \ride\library\event\Event $event Triggered event
  * @param \ride\library\i18n\I18N $i18n
  * @param \ride\web\WebApplication $web
  * @param \ride\library\event\EventManager $eventManager
  * @return null
  */
 public function prepareTaskbar(Event $event, I18n $i18n, WebApplication $web, EventManager $eventManager)
 {
     $locale = null;
     $request = $web->getRequest();
     $route = $request->getRoute();
     if ($route) {
         $locale = $route->getArgument('locale');
     }
     if (!$locale && $request->hasSession()) {
         $session = $request->getSession();
         $locale = $session->get(AbstractController::SESSION_LOCALE_CONTENT);
     }
     if (!$locale) {
         $locale = $i18n->getLocale()->getCode();
     }
     $taskbar = $event->getArgument('taskbar');
     $applicationMenu = $taskbar->getApplicationsMenu();
     $referer = '?referer=' . urlencode($request->getUrl());
     // site menu
     $menu = new Menu();
     $menu->setId('sites.menu');
     $menu->setTranslation('label.sites');
     $defaultRevision = $this->cms->getDefaultRevision();
     $draftRevision = $this->cms->getDraftRevision();
     $sites = $this->cms->getSites();
     if ($sites) {
         foreach ($sites as $siteId => $site) {
             $availableLocales = $site->getAvailableLocales();
             if ($availableLocales == Node::LOCALES_ALL || isset($availableLocales[$locale])) {
                 $siteLocale = $locale;
             } else {
                 $siteLocale = reset($availableLocales);
             }
             if ($site->hasRevision($draftRevision)) {
                 $revision = $draftRevision;
             } elseif ($site->hasRevision($defaultRevision)) {
                 $revision = $defaultRevision;
             } else {
                 $revision = $site->getRevision();
             }
             $menuItem = new MenuItem();
             $menuItem->setLabel($site->getName($locale));
             $menuItem->setRoute('cms.site.detail.locale', array('site' => $site->getId(), 'revision' => $revision, 'locale' => $siteLocale));
             $menu->addMenuItem($menuItem);
         }
     }
     $url = $web->getUrl('cms.site.add', array('locale' => $locale)) . $referer;
     if ($this->securityManager->isUrlAllowed($url)) {
         if ($menu->hasItems()) {
             $menu->addSeparator();
         }
         $menuItem = new MenuItem();
         $menuItem->setTranslation('button.site.add');
         $menuItem->setUrl($url);
         $menu->addMenuItem($menuItem);
     }
     $applicationMenu->addMenu($menu);
     // theme menu
     $menu = new Menu();
     $menu->setId('themes.menu');
     $menu->setTranslation('label.themes');
     $themes = $this->cms->getThemes();
     if ($themes) {
         foreach ($themes as $theme) {
             $menuItem = new MenuItem();
             $menuItem->setLabel($theme->getDisplayName());
             $menuItem->setUrl($web->getUrl('cms.theme.edit', array('theme' => $theme->getName())) . $referer);
             $menu->addMenuItem($menuItem);
         }
         $menu->addSeparator();
     }
     $menuItem = new MenuItem();
     $menuItem->setTranslation('button.theme.add');
     $menuItem->setUrl($web->getUrl('cms.theme.add') . $referer);
     $menu->addMenuItem($menuItem);
     $applicationMenu->addMenu($menu);
 }