![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/amasty/shopby/Model/StoreSwitcher/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Improved Layered Navigation Base for Magento 2 */ namespace Amasty\Shopby\Model\StoreSwitcher; use Amasty\Shopby\Plugin\Store\ViewModel\SwitcherUrlProvider\ModifyUrlData; use Amasty\ShopbyBase\Model\UrlBuilder\UrlModifier; use Magento\Framework\App\RequestInterface; use Magento\Store\Api\Data\StoreInterface; use Magento\Store\Model\StoreSwitcherInterface; class ModifyUrl implements StoreSwitcherInterface { /** * @var UrlModifier */ private $urlModifier; /** * @var CategoryRegistry */ private $categoryRegistry; /** * @var RequestInterface */ private $request; public function __construct(UrlModifier $urlModifier, CategoryRegistry $categoryRegistry, RequestInterface $request) { $this->urlModifier = $urlModifier; $this->categoryRegistry = $categoryRegistry; $this->request = $request; } /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function switch(StoreInterface $fromStore, StoreInterface $targetStore, string $redirectUrl): string { $categoryId = $this->request->getParam(ModifyUrlData::CATEGORY_ID, $this->categoryRegistry->get()); if ($categoryId === null) { return $redirectUrl; } return $this->urlModifier->execute($redirectUrl, (int) $categoryId, true); } }