/** * Delete custom admin url from configuration if "Use Custom Admin Url" option disabled * * @return $this */ public function afterSave() { $value = $this->getValue(); if (!$value) { $this->_configWriter->delete(Custom::XML_PATH_SECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID); $this->_configWriter->delete(Custom::XML_PATH_UNSECURE_BASE_URL, Custom::CONFIG_SCOPE, Custom::CONFIG_SCOPE_ID); } return $this; }
/** * Unassign given theme from stores that were unchecked * * @param string $themeId * @param array $stores * @param string $scope * @param bool &$isReassigned * @return $this */ protected function _unassignThemeFromStores($themeId, $stores, $scope, &$isReassigned) { $configPath = \Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID; foreach ($this->_getAssignedScopesCollection($scope, $configPath) as $config) { if ($config->getValue() == $themeId && !in_array($config->getScopeId(), $stores)) { $this->_configWriter->delete($configPath, $scope, $config->getScopeId()); $isReassigned = true; } } return $this; }
/** * @param InputInterface $input * @param \Magento\Framework\App\Config\Storage\WriterInterface $configWriter * @param $path * @param $scopeId * * @return array */ protected function _deletePath(InputInterface $input, \Magento\Framework\App\Config\Storage\WriterInterface $configWriter, $path, $scopeId) { $deleted = array(); if ($input->getOption('all')) { $storeManager = $this->getObjectManager()->get('Magento\\Store\\Model\\StoreManager'); // Default $configWriter->delete($path, 'default', 0); $deleted[] = array('path' => $path, 'scope' => 'default', 'scopeId' => 0); foreach ($storeManager->getWebsites() as $website) { $configWriter->delete($path, 'websites', $website->getId()); $deleted[] = array('path' => $path, 'scope' => 'websites', 'scopeId' => $website->getId()); } // Delete stores foreach ($storeManager->getStores() as $store) { $configWriter->delete($path, 'stores', $store->getId()); $deleted[] = array('path' => $path, 'scope' => 'stores', 'scopeId' => $store->getId()); } } else { $configWriter->delete($path, $input->getOption('scope'), $scopeId); $deleted[] = array('path' => $path, 'scope' => $input->getOption('scope'), 'scopeId' => $scopeId); } return $deleted; }