/** * Returns whether page should be considered active or not * * This method will compare the page properties against the route matches * composed in the object. * * @param bool $recursive [optional] whether page should be considered * active if any child pages are active. Default is * false. * @return bool whether page should be considered active or not */ public function isActive($recursive = false) { if (!$this->active) { $reqParams = array(); if ($this->routeMatch instanceof RouteMatch) { $reqParams = $this->routeMatch->getParams(); if (isset($reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER])) { $reqParams['controller'] = $reqParams[ModuleRouteListener::ORIGINAL_CONTROLLER]; } $myParams = $this->params; if (null !== $this->controller) { $myParams['controller'] = $this->controller; } if (null !== $this->action) { $myParams['action'] = $this->action; } if (null !== $this->getRoute() && $this->routeMatch->getMatchedRouteName() === $this->getRoute() && count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) { $this->active = true; return true; } } $myParams = $this->params; if (null !== $this->controller) { $myParams['controller'] = $this->controller; } else { /** * @todo In ZF1, this was configurable and pulled from the front controller */ $myParams['controller'] = 'index'; } if (null !== $this->action) { $myParams['action'] = $this->action; } else { /** * @todo In ZF1, this was configurable and pulled from the front controller */ $myParams['action'] = 'index'; } if (count(array_intersect_assoc($reqParams, $myParams)) == count($myParams)) { $this->active = true; return true; } } return parent::isActive($recursive); }