_defaultPath = $defaultPath; } /** * Get href URL * * @return string */ public function getHref() { return $this->getUrl($this->getPath()); } /** * Get current mca * * @return string * @SuppressWarnings(PHPMD.RequestAwareBlockMethod) */ private function getMca() { $routeParts = [ (string)$this->_request->getModuleName(), (string)$this->_request->getControllerName(), (string)$this->_request->getActionName(), ]; $parts = []; $pathParts = explode('/', trim($this->_request->getPathInfo(), '/')); foreach ($routeParts as $key => $value) { if (isset($pathParts[$key]) && $pathParts[$key] === $value) { $parts[] = $value; } } return implode('/', $parts); } /** * Check if link leads to URL equivalent to URL of currently displayed page * * @return bool */ public function isCurrent() { return $this->getCurrent() || $this->getUrl($this->getPath()) == $this->getUrl($this->getMca()); } /** * Render block HTML * * @return string */ protected function _toHtml() { if (false != $this->getTemplate()) { return parent::_toHtml(); } $highlight = ''; if ($this->getIsHighlighted()) { $highlight = ' current'; } if ($this->isCurrent()) { $html = ''; } else { $html = ''; } return $html; } /** * Generate attributes' HTML code * * @return string */ private function getAttributesHtml() { $attributesHtml = ''; $attributes = $this->getAttributes(); if ($attributes) { foreach ($attributes as $attribute => $value) { $attributesHtml .= ' ' . $attribute . '="' . $this->escapeHtml($value) . '"'; } } return $attributesHtml; } }