_configWriter = $configWriter; parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); } /** * Validate custom url * * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ public function beforeSave() { $value = $this->getValue(); if ($value == 1) { $customUrl = $this->getData('groups/url/fields/custom/value'); if (empty($customUrl)) { throw new \Magento\Framework\Exception\LocalizedException(__('Please specify the admin custom URL.')); } } return $this; } /** * 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 parent::afterSave(); } }