+ /**
+ * Remove a config element from the config file.
+ *
+ * @param string $setting Asked setting, keys separated with dots.
+ * @param bool $write Write the new setting in the config file, default false.
+ * @param bool $isLoggedIn User login state, default false.
+ *
+ * @throws \Exception Invalid
+ */
+ public function remove($setting, $write = false, $isLoggedIn = false)
+ {
+ if (empty($setting) || ! is_string($setting)) {
+ throw new \Exception(t('Invalid setting key parameter. String expected, got: '). gettype($setting));
+ }
+
+ // During the ConfigIO transition, map legacy settings to the new ones.
+ if ($this->configIO instanceof ConfigPhp && isset(ConfigPhp::$LEGACY_KEYS_MAPPING[$setting])) {
+ $setting = ConfigPhp::$LEGACY_KEYS_MAPPING[$setting];
+ }
+
+ $settings = explode('.', $setting);
+ self::removeConfig($settings, $this->loadedConfig);
+ if ($write) {
+ $this->write($isLoggedIn);
+ }
+ }
+