Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function main(App $app)
 {
     $app['node'] = function ($app) {
         if ($id = $app['request']->attributes->get('_node') and $node = Node::find($id, true)) {
             return $node;
         }
         return Node::create();
     };
     $app['menu'] = function ($app) {
         $menus = new MenuManager($app->config($app['theme']->name), $this->config('menus'));
         foreach ($app['theme']->get('menus', []) as $name => $label) {
             $menus->register($name, $label);
         }
         return $menus;
     };
     $app->extend('view', function ($view) use($app) {
         return $view->addHelper(new MenuHelper($app['menu']));
     });
 }
Пример #2
0
 /**
  * Checks if the menu exists.
  *
  * @param  string $name
  * @return bool
  */
 public function exists($name)
 {
     return (bool) $this->menus->find($name);
 }