normalizeItems() защищенный Метод

Normalizes the [[items]] property to remove invisible items and activate certain items.
protected normalizeItems ( array $items, boolean &$active ) : array
$items array the items to be normalized.
$active boolean whether there is an active child menu item.
Результат array the normalized menu items
Пример #1
0
 protected function normalizeItems($items, &$active)
 {
     $currentUrl = ltrim(P::$app->getRequest()->getUrl(), '/');
     $langList = [];
     foreach (P::$app->getLocale()->enableLocales as $lang) {
         if ($lang !== P::$app->getLocale()->defaultLocale) {
             $langList[] = $lang;
         }
     }
     foreach ($items as $i => $item) {
         if (!isset($item['lang'])) {
             throw new InvalidConfigException('The "lang" element is required for each item.');
         }
         if (in_array($item['lang'], $langList)) {
             $items[$i]['url'] = '/' . $item['lang'] . '/' . $currentUrl;
         } else {
             $items[$i]['url'] = $currentUrl;
         }
     }
     return parent::normalizeItems($items, $active);
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 protected function normalizeItems($items, &$active)
 {
     $items = parent::normalizeItems($items, $active);
     foreach ($items as $i => $item) {
         $items[$i]['icon'] = ArrayHelper::getValue($item, 'icon', '');
         if (isset($item['items']) && !isset($item['url'])) {
             $items[$i]['url'] = '#';
         }
     }
     return $items;
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 protected function normalizeItems($items, &$active)
 {
     foreach ($items as $i => &$item) {
         if ($item['visible'] instanceof Closure) {
             $item['visible'] = call_user_func($item['visible']);
         }
     }
     return parent::normalizeItems($items, $active);
 }