AsyncIndexing.php 963 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 33 34 35 36 37 38
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Sales\Model\Config\Backend\Grid;

/**
 * Backend model for global configuration value
 * 'dev/grid/async_indexing'.
 */
class AsyncIndexing extends \Magento\Framework\App\Config\Value
{
    /**
     * Dispatches corresponding event after saving of configuration
     * value if it was changed.
     *
     * Dispatches next events:
     *
     * - config_data_dev_grid_async_indexing_enabled
     * - config_data_dev_grid_async_indexing_disabled
     *
     * @return $this
     */
    public function afterSave()
    {
        if ($this->isValueChanged()) {
            $state = $this->getValue() ? 'enabled' : 'disabled';

            $this->_eventManager->dispatch(
                $this->_eventPrefix . '_dev_grid_async_indexing_' . $state,
                $this->_getEventData()
            );
        }

        return $this;
    }
}