|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | +declare(strict_types=1); |
| 7 | + |
6 | 8 | namespace Magento\Catalog\Plugin\Block;
|
7 | 9 |
|
8 | 10 | use Magento\Catalog\Model\Category;
|
@@ -156,12 +158,13 @@ private function getCurrentCategory()
|
156 | 158 | */
|
157 | 159 | private function getCategoryAsArray($category, $currentCategory, $isParentActive)
|
158 | 160 | {
|
| 161 | + $categoryId = $category->getId(); |
159 | 162 | return [
|
160 | 163 | 'name' => $category->getName(),
|
161 |
| - 'id' => 'category-node-' . $category->getId(), |
| 164 | + 'id' => 'category-node-' . $categoryId, |
162 | 165 | 'url' => $this->catalogCategory->getCategoryUrl($category),
|
163 |
| - 'has_active' => in_array((string)$category->getId(), explode('/', $currentCategory->getPath()), true), |
164 |
| - 'is_active' => $category->getId() == $currentCategory->getId(), |
| 166 | + 'has_active' => in_array((string)$categoryId, explode('/', (string)$currentCategory->getPath()), true), |
| 167 | + 'is_active' => $categoryId == $currentCategory->getId(), |
165 | 168 | 'is_category' => true,
|
166 | 169 | 'is_parent_active' => $isParentActive
|
167 | 170 | ];
|
@@ -200,6 +203,7 @@ protected function getCategoryTree($storeId, $rootId)
|
200 | 203 | * @param \Magento\Theme\Block\Html\Topmenu $subject
|
201 | 204 | * @param string[] $result
|
202 | 205 | * @return string[]
|
| 206 | + * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
203 | 207 | */
|
204 | 208 | public function afterGetCacheKeyInfo(\Magento\Theme\Block\Html\Topmenu $subject, array $result)
|
205 | 209 | {
|
|
0 commit comments