MultishippingErrorMessageSupport.php 1.21 KB
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?php
/**
 * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
 * @author     Mediotype                     https://www.mediotype.com/
 */

namespace Vertex\Tax\Model\Plugin;

use Magento\Framework\App\ActionInterface;
use Vertex\Tax\Model\Config;
use Vertex\Tax\Model\ErrorMessageDisplayState;

/**
 * Turn on error messages during Multishipping
 */
class MultishippingErrorMessageSupport
{
    /** @var Config */
    private $config;

    /** @var ErrorMessageDisplayState */
    private $messageDisplayState;

    /**
     * @param ErrorMessageDisplayState $messageDisplayState
     * @param Config $config
     */
    public function __construct(
        ErrorMessageDisplayState $messageDisplayState,
        Config $config
    ) {
        $this->messageDisplayState = $messageDisplayState;
        $this->config = $config;
    }

    /**
     * Turn on error messages
     *
     * @param ActionInterface $subject
     * @return void
     * @SuppressWarnings(PHPMD.UnusedFormalParameter) $subject required for interceptor
     */
    public function beforeExecute(ActionInterface $subject)
    {
        if ($this->config->isVertexActive()) {
            $this->messageDisplayState->enable();
        }
    }
}