/** * Checks whether a menu item is active. * This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item. * When the `url` option of a menu item is specified in terms of an array, its first element is treated * as the route for the item and the rest of the elements are the associated parameters. * Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item * be considered active. * @param array $item the menu item to be checked * @return boolean whether the menu item is active */ protected function isItemActive($item) { if (isset($item['childUrls']) && is_array($item['childUrls']) && isset($item['childUrls'][0])) { foreach ($item['childUrls'] as $childUrls) { $route = $childUrls; if ($route[0] !== '/' && Yii::$app->controller) { $route = Yii::$app->controller->module->getUniqueId() . '/' . $route; } if (ltrim($route, '/') === $this->route) { return true; } } } return parent::isItemActive($item); }