|
5 | 5 | */
|
6 | 6 | namespace Magento\Framework\View\Element\Html\Link;
|
7 | 7 |
|
| 8 | +use Magento\Framework\App\DefaultPathInterface; |
| 9 | +use Magento\Framework\View\Element\Template; |
| 10 | +use Magento\Framework\View\Element\Template\Context; |
| 11 | + |
8 | 12 | /**
|
9 | 13 | * Block representing link with two possible states.
|
10 | 14 | * "Current" state means link leads to URL equivalent to URL of currently displayed page.
|
|
17 | 21 | * @method null|bool getCurrent()
|
18 | 22 | * @method \Magento\Framework\View\Element\Html\Link\Current setCurrent(bool $value)
|
19 | 23 | */
|
20 |
| -class Current extends \Magento\Framework\View\Element\Template |
| 24 | +class Current extends Template |
21 | 25 | {
|
22 | 26 | /**
|
23 | 27 | * Default path
|
24 | 28 | *
|
25 |
| - * @var \Magento\Framework\App\DefaultPathInterface |
| 29 | + * @var DefaultPathInterface |
26 | 30 | */
|
27 | 31 | protected $_defaultPath;
|
28 | 32 |
|
29 | 33 | /**
|
30 | 34 | * Constructor
|
31 | 35 | *
|
32 |
| - * @param \Magento\Framework\View\Element\Template\Context $context |
33 |
| - * @param \Magento\Framework\App\DefaultPathInterface $defaultPath |
| 36 | + * @param Context $context |
| 37 | + * @param DefaultPathInterface $defaultPath |
34 | 38 | * @param array $data
|
35 | 39 | */
|
36 | 40 | public function __construct(
|
37 |
| - \Magento\Framework\View\Element\Template\Context $context, |
38 |
| - \Magento\Framework\App\DefaultPathInterface $defaultPath, |
| 41 | + Context $context, |
| 42 | + DefaultPathInterface $defaultPath, |
39 | 43 | array $data = []
|
40 | 44 | ) {
|
41 | 45 | parent::__construct($context, $data);
|
@@ -81,7 +85,7 @@ private function getMca()
|
81 | 85 | */
|
82 | 86 | public function isCurrent()
|
83 | 87 | {
|
84 |
| - return $this->getCurrent() || $this->getUrl($this->getPath()) == $this->getUrl($this->getMca()); |
| 88 | + return $this->getCurrent() || $this->getUrl($this->getPath()) == $this->getUrl($this->getPathInfo()); |
85 | 89 | }
|
86 | 90 |
|
87 | 91 | /**
|
@@ -147,4 +151,14 @@ private function getAttributesHtml()
|
147 | 151 |
|
148 | 152 | return $attributesHtml;
|
149 | 153 | }
|
| 154 | + |
| 155 | + /** |
| 156 | + * Get current page path info |
| 157 | + * |
| 158 | + * @return string |
| 159 | + */ |
| 160 | + private function getPathInfo() |
| 161 | + { |
| 162 | + return trim($this->_request->getPathInfo(), '/'); |
| 163 | + } |
150 | 164 | }
|
0 commit comments