Exemple #1
0
 /**
  * Gets the menu items indexed by their name with a value of the title.
  *
  * @param array $subMenu (used for recursion)
  *
  * @return array
  */
 public function getMenu($subMenu = null)
 {
     $menu = array();
     if (!$subMenu) {
         $subMenu = $this->config->get('administrator.menu');
     }
     //iterate over the menu to build the return array of valid menu items
     foreach ($subMenu as $key => $item) {
         //if the item is a string, find its config
         if (is_string($item)) {
             //fetch the appropriate config file
             $config = $this->configFactory->make($item);
             //if a config object was returned and if the permission passes, add the item to the menu
             if (is_a($config, 'Frozennode\\Administrator\\Config\\Config') && $config->getOption('permission')) {
                 $menu[$item] = $config->getOption('title');
             } elseif ($config === true) {
                 $menu[$item] = $key;
             }
         } elseif (is_array($item)) {
             $menu[$key] = $this->getMenu($item);
             //if the submenu is empty, unset it
             if (empty($menu[$key])) {
                 unset($menu[$key]);
             }
         }
     }
     return $menu;
 }
 public function testModelNotInMenu()
 {
     $name = 'some_model';
     $factory = new Factory($this->validator, $this->validator, array('menu' => array()));
     $this->assertEquals($factory->searchMenu($name), false);
 }