<?php
/**
 * Magetop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magetop.com license that is
 * available through the world-wide-web at this URL:
 * https://www.magetop.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Magetop
 * @package     Magetop_QuickFlushCache
 * @copyright   Copyright (c) Magetop (https://www.magetop.com/)
 * @license     https://www.magetop.com/LICENSE.txt
 */

namespace Magetop\QuickFlushCache\Plugin\Model\Message;

use Magento\Indexer\Model\Message\Invalid as IndexerInvalid;
use Magetop\QuickFlushCache\Helper\Data as HelperData;

/**
 * Class Invalid
 * @package Magetop\QuickFlushCache\Plugin\Model\Message
 */
class Invalid
{
    /**
     * @var HelperData
     */
    protected $_helperData;

    /**
     * Invalid constructor.
     *
     * @param HelperData $helperData
     */
    public function __construct(
        HelperData $helperData
    ) {
        $this->_helperData = $helperData;
    }

    /**
     * @param IndexerInvalid $subject
     * @param $result
     * @SuppressWarnings(Unused)
     *
     * @return mixed
     */
    public function afterGetText(IndexerInvalid $subject, $result)
    {
        if ($this->_helperData->isEnabledReindex()) {
            $result .= ' <a id="mp-qfc-reindex" href="#">' . __('Reindex Now!') . '</a>';
        }

        return $result;
    }
}
