SwitcherPlugin.php 879 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Paypal\Block\Adminhtml\Store;

use Magento\Backend\Block\Store\Switcher as StoreSwitcherBlock;
use Magento\Paypal\Model\Config\StructurePlugin as ConfigStructurePlugin;

/**
 * Plugin for \Magento\Backend\Block\Store\Switcher
 */
class SwitcherPlugin
{
    /**
     * Remove country request param from url
     *
     * @param StoreSwitcherBlock $subject
     * @param string $route
     * @param array $params
     * @return array
     */
    public function beforeGetUrl(StoreSwitcherBlock $subject, $route = '', $params = [])
    {
        if ($subject->getRequest()->getParam(ConfigStructurePlugin::REQUEST_PARAM_COUNTRY)) {
            $params[ConfigStructurePlugin::REQUEST_PARAM_COUNTRY] = null;
        }

        return [$route, $params];
    }
}