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); }
/** * @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; }
/** * {@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); }