Spamworldpro Mini Shell
Spamworldpro


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/cartforge.co/app/code/Amasty/MWishlist/Controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/app/code/Amasty/MWishlist/Controller/Router.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Multiple Wishlist for Magento 2
 */

namespace Amasty\MWishlist\Controller;

use Amasty\MWishlist\Model\ConfigProvider;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\RouterInterface;

/**
 * 'wishlist/index/index' on EE (Magento_MultipleWishlist)
 * - open controller which redirect on first wishlist ignoring wishlist_id
 *
 * Class Router
 */
class Router implements RouterInterface
{
    public const FORWARDS = [
        'wishlist/index/index' => [
            'mwishlist',
            'wishlist',
            'index'
        ]
    ];

    /**
     * @var ConfigProvider
     */
    private $configProvider;

    public function __construct(ConfigProvider $configProvider)
    {
        $this->configProvider = $configProvider;
    }

    /**
     * @param RequestInterface $request
     */
    public function match(RequestInterface $request)
    {
        $requestUrl = $this->retrieveRoute($request);

        if ($this->configProvider->isEnabled()
            && isset(self::FORWARDS[$requestUrl])
        ) {
            $request->setModuleName(self::FORWARDS[$requestUrl][0]);
            $request->setControllerName(self::FORWARDS[$requestUrl][1]);
            $request->setActionName(self::FORWARDS[$requestUrl][2]);
        }
    }

    /**
     * @param RequestInterface $request
     * @return string
     */
    protected function retrieveRoute(RequestInterface $request): string
    {
        $output = [];

        $path = trim($request->getPathInfo(), '/');

        $params = explode('/', $path ?: '');
        while (count($output) < 3) {
            $output[] = array_shift($params) ?: 'index';
        }

        return implode('/', $output);
    }
}

Spamworldpro Mini