reinitableConfig = $reinitableConfig; $this->indexerRegistry = $indexerRegistry; $this->configStorage = $configStorage; } /** * Get config validator * * @return Design\Config\Validator * * @deprecated 100.1.0 */ private function getValidator() { if (null === $this->validator) { $this->validator =\Magento\Framework\App\ObjectManager::getInstance()->get( \Magento\Theme\Model\Design\Config\Validator::class ); } return $this->validator; } /** * @inheritDoc */ public function getByScope($scope, $scopeId) { return $this->configStorage->load($scope, $scopeId); } /** * @inheritDoc */ public function save(DesignConfigInterface $designConfig) { if (!($designConfig->getExtensionAttributes() && $designConfig->getExtensionAttributes()->getDesignConfigData()) ) { throw new LocalizedException( __("The config can't be saved because it's empty. Complete the config and try again.") ); } $this->getValidator()->validate($designConfig); $this->configStorage->save($designConfig); $this->reinitableConfig->reinit(); $this->reindexGrid(); return $designConfig; } /** * @inheritDoc */ public function delete(DesignConfigInterface $designConfig) { if (!($designConfig->getExtensionAttributes() && $designConfig->getExtensionAttributes()->getDesignConfigData()) ) { throw new LocalizedException( __("The config can't be saved because it's empty. Complete the config and try again.") ); } $this->configStorage->delete($designConfig); $this->reinitableConfig->reinit(); $this->reindexGrid(); return $designConfig; } /** * Synchronize design config grid * * @return void */ protected function reindexGrid() { $this->indexerRegistry->get(DesignConfig::DESIGN_CONFIG_GRID_INDEXER_ID)->reindexAll(); } }