getEvent()->getObject() in this case * * @var string */ protected $_eventObject = 'config_data'; /** * @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $_config; /** * @var \Magento\Framework\App\Cache\TypeListInterface */ protected $cacheTypeList; /** * @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Registry $registry * @param ScopeConfigInterface $config * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection * @param array $data */ public function __construct( \Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [] ) { $this->_config = $config; $this->cacheTypeList = $cacheTypeList; parent::__construct($context, $registry, $resource, $resourceCollection, $data); } /** * Check if config data value was changed * * @return bool */ public function isValueChanged() { return $this->getValue() != $this->getOldValue(); } /** * Get old value from existing config * * @return string */ public function getOldValue() { return (string)$this->_config->getValue( $this->getPath(), $this->getScope() ?: ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $this->getScopeCode() ); } /** * Get value by key for new user data from
/groups//fields/ * * @param string $key * @return string */ public function getFieldsetDataValue($key) { $data = $this->_getData('fieldset_data'); return is_array($data) && isset($data[$key]) ? $data[$key] : null; } /** * Processing object after save data * * {@inheritdoc}. In addition, it sets status 'invalidate' for config caches * * @return $this */ public function afterSave() { if ($this->isValueChanged()) { $this->cacheTypeList->invalidate(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER); } return parent::afterSave(); } /** * Processing object after delete data * * {@inheritdoc}. In addition, it sets status 'invalidate' for config caches * * @return $this * @since 100.1.0 */ public function afterDelete() { $this->cacheTypeList->invalidate(\Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER); return parent::afterDelete(); } }