Esempio n. 1
0
 /**
  * @param \DK\Menu\Menu $menu
  * @param string $title
  * @param string $target
  * @param array $parameters
  */
 public function __construct(Menu $menu, $title, $target, array $parameters = array())
 {
     parent::__construct();
     $this->menu = $menu;
     $this->setTitle($title);
     $this->setTarget($target);
     $this->setParameters($parameters);
 }
Esempio n. 2
0
 /**
  * @param \Nette\Security\User $user
  * @param string $name
  */
 public function __construct(User $user, $name)
 {
     parent::__construct(null, $name);
     $this->user = $user;
 }
Esempio n. 3
0
 /**
  * @param \DK\Menu\Container $parent
  * @param array $items
  */
 private static function addItemsToParent(Container $parent, array $items)
 {
     foreach ($items as $data) {
         $item = $parent->addItem($data['title'], $data['target'], $data['parameters'], $data['name']);
         if (count($data['data']) > 0) {
             $item->setData($data['data']);
         }
         if ($data['include'] !== null) {
             $item->setInclude($data['include']);
         }
         if ($data['visual'] !== null) {
             $item->setVisual($data['visual']);
         }
         if ($data['allow']['loggedIn'] !== null) {
             $item->setAllowedForLoggedIn($data['allow']['loggedIn']);
         }
         if (count($data['allow']['roles']) > 0) {
             $item->setAllowedForRoles($data['allow']['roles']);
         }
         if ($data['allow']['module'] !== null) {
             $item->setAllowedForModule($data['allow']['module']);
         }
         if (count($data['allow']['parameters']) > 0) {
             $item->setAllowedForParameters($data['allow']['parameters']);
         }
         if (count($data['allow']['acl']) > 0) {
             if (isset($data['allow']['acl']['resource'])) {
                 $permission = null;
                 if (isset($data['allow']['acl']['permission'])) {
                     $permission = $data['allow']['acl']['permission'];
                 }
                 $item->setAllowedForAcl($data['allow']['acl']['resource'], $permission);
             }
         }
         if (count($data['items']) > 0) {
             self::addItemsToParent($item, $data['items']);
         }
     }
 }