/** * @param DesignConfigRepository $subject * @param DesignConfigInterface $designConfig * @return DesignConfigInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterDelete(DesignConfigRepository $subject, DesignConfigInterface $designConfig) { $website = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_WEBSITE, ScopeInterface::SCOPE_WEBSITES]) ? $this->storeManager->getWebsite($designConfig->getScopeId()) : ''; $store = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_STORE, ScopeInterface::SCOPE_STORES]) ? $this->storeManager->getStore($designConfig->getScopeId()) : ''; $this->eventManager->dispatch('admin_system_config_changed_section_design', ['website' => $website, 'store' => $store]); return $designConfig; }
/** * Delete design configuration from storage * * @param DesignConfigInterface $designConfig * @return void */ public function delete(DesignConfigInterface $designConfig) { $fieldsData = $designConfig->getExtensionAttributes()->getDesignConfigData(); /* @var $deleteTransaction \Magento\Framework\DB\Transaction */ $deleteTransaction = $this->transactionFactory->create(); foreach ($fieldsData as $fieldData) { /** @var ValueInterface|Value $backendModel */ $backendModel = $this->backendModelFactory->create(['value' => $fieldData->getValue(), 'scope' => $designConfig->getScope(), 'scopeId' => $designConfig->getScopeId(), 'config' => $fieldData->getFieldConfig()]); if (!$backendModel->isObjectNew()) { $deleteTransaction->addObject($backendModel); } } $deleteTransaction->delete(); }