Commit ea1dd457 authored by catch's avatar catch

Issue #2406543 by alexpott: Remove ConfigFactory::setOverrideState and...

Issue #2406543 by alexpott: Remove ConfigFactory::setOverrideState and ConfigFactory::getOverrideState()
parent 0584b186
......@@ -43,13 +43,6 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface
*/
protected $eventDispatcher;
/**
* A flag indicating if we should use overrides.
*
* @var boolean
*/
protected $useOverrides = TRUE;
/**
* Cached configuration objects.
*
......@@ -87,30 +80,11 @@ public function __construct(StorageInterface $storage, EventDispatcherInterface
$this->typedConfigManager = $typed_config;
}
/**
* {@inheritdoc}
*/
public function setOverrideState($state) {
$this->useOverrides = $state;
return $this;
}
/**
* {@inheritdoc}
*/
public function getOverrideState() {
return $this->useOverrides;
}
/**
* {@inheritdoc}
*/
public function getEditable($name) {
$old_state = $this->getOverrideState();
$this->setOverrideState(FALSE);
$config = $this->doGet($name, FALSE);
$this->setOverrideState($old_state);
return $config;
return $this->doGet($name, FALSE);
}
/**
......@@ -141,7 +115,7 @@ protected function doGet($name, $immutable = TRUE) {
$cache_key = $this->getConfigCacheKey($name, $immutable);
$this->cache[$cache_key] = $this->createConfigObject($name, $immutable);
if ($this->useOverrides) {
if ($immutable) {
// Get and apply any overrides.
$overrides = $this->loadOverrides(array($name));
if (isset($overrides[$name])) {
......@@ -191,7 +165,7 @@ protected function doLoadMultiple(array $names, $immutable = TRUE) {
$module_overrides = array();
$storage_data = $this->storage->readMultiple($names);
if ($this->useOverrides && !empty($storage_data)) {
if ($immutable && !empty($storage_data)) {
// Only get module overrides if we have configuration to override.
$module_overrides = $this->loadOverrides($names);
}
......@@ -201,7 +175,7 @@ protected function doLoadMultiple(array $names, $immutable = TRUE) {
$this->cache[$cache_key] = $this->createConfigObject($name, $immutable);
$this->cache[$cache_key]->initWithData($data);
if ($this->useOverrides) {
if ($immutable) {
if (isset($module_overrides[$name])) {
$this->cache[$cache_key]->setModuleOverride($module_overrides[$name]);
}
......@@ -278,20 +252,17 @@ public function rename($old_name, $new_name) {
* {@inheritdoc}
*/
public function getCacheKeys() {
$keys = array();
if ($this->useOverrides) {
// Because get() adds overrides both from $GLOBALS and from
// $this->configFactoryOverrides, add cache keys for each.
$keys[] = 'global_overrides';
foreach($this->configFactoryOverrides as $override) {
$keys[] = $override->getCacheSuffix();
}
// Because get() adds overrides both from $GLOBALS and from
// $this->configFactoryOverrides, add cache keys for each.
$keys[] = 'global_overrides';
foreach($this->configFactoryOverrides as $override) {
$keys[] = $override->getCacheSuffix();
}
return $keys;
}
/**
* Gets the cache key for a given config name.
* Gets the static cache key for a given config name.
*
* @param string $name
* The name of the configuration object.
......@@ -302,7 +273,11 @@ public function getCacheKeys() {
* The cache key.
*/
protected function getConfigCacheKey($name, $immutable) {
return $name . ':' . implode(':', $this->getCacheKeys()) . ':' . ($immutable ? static::IMMUTABLE: static::MUTABLE);
$suffix = '';
if ($immutable) {
$suffix = ':' . implode(':', $this->getCacheKeys());
}
return $name . $suffix;
}
/**
......@@ -316,8 +291,9 @@ protected function getConfigCacheKey($name, $immutable) {
*/
protected function getConfigCacheKeys($name) {
return array_filter(array_keys($this->cache), function($key) use ($name) {
// Return TRUE if the key starts with the configuration name.
return strpos($key, $name . ':') === 0;
// Return TRUE if the key is the name or starts with the configuration
// name plus the delimiter.
return $key === $name || strpos($key, $name . ':') === 0;
});
}
......
......@@ -14,34 +14,6 @@
*/
interface ConfigFactoryInterface {
/**
* Constant used in static cache keys for mutable config objects.
*/
const MUTABLE = 'mutable';
/**
* Constant used in static cache keys for immutable config objects.
*/
const IMMUTABLE = 'immutable';
/**
* Sets the override state.
*
* @param bool $state
* TRUE if overrides should be applied, FALSE otherwise.
*
* @return $this
*/
public function setOverrideState($state);
/**
* Gets the override state.
*
* @return bool
* Get the override state.
*/
public function getOverrideState();
/**
* Returns an immutable configuration object for a given name.
*
......
......@@ -99,9 +99,6 @@ public function installDefaultConfig($type, $name) {
// Gather information about all the supported collections.
$collection_info = $this->configManager->getConfigCollectionInfo();
$old_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
// Read enabled extensions directly from configuration to avoid circular
// dependencies with ModuleHandler and ThemeHandler.
$extension_config = $this->configFactory->get('core.extension');
......@@ -124,7 +121,7 @@ public function installDefaultConfig($type, $name) {
$this->createConfiguration($collection, $config_to_install);
}
}
$this->configFactory->setOverrideState($old_state);
// Reset all the static caches and list caches.
$this->configFactory->reset();
}
......@@ -255,10 +252,7 @@ public function installCollectionDefaultConfig($collection) {
return in_array($provider, $enabled_extensions);
});
if (!empty($config_to_install)) {
$old_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
$this->createConfiguration($collection, $config_to_install);
$this->configFactory->setOverrideState($old_state);
// Reset all the static caches and list caches.
$this->configFactory->reset();
}
......
......@@ -92,6 +92,13 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
*/
protected $entities = array();
/**
* Determines if the underlying configuration is retrieved override free.
*
* @var bool
*/
protected $overrideFree = FALSE;
/**
* Constructs a ConfigEntityStorage object.
*
......@@ -179,7 +186,7 @@ protected function doLoadMultiple(array $ids = NULL) {
// Load all of the configuration entities.
$records = array();
foreach ($this->configFactory->loadMultiple($names) as $config) {
$records[$config->get($this->idKey)] = $config->get();
$records[$config->get($this->idKey)] = $this->overrideFree ? $config->getOriginal(NULL, FALSE) : $config->get();
}
return $this->mapFromStorageRecords($records);
}
......@@ -289,7 +296,7 @@ protected function getFromStaticCache(array $ids) {
$entities = array();
// Load any available entities from the internal cache.
if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) {
$config_overrides_key = implode(':', $this->configFactory->getCacheKeys());
$config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys());
foreach ($ids as $id) {
if (!empty($this->entities[$id])) {
if (isset($this->entities[$id][$config_overrides_key])) {
......@@ -309,7 +316,7 @@ protected function getFromStaticCache(array $ids) {
*/
protected function setStaticCache(array $entities) {
if ($this->entityType->isStaticallyCacheable()) {
$config_overrides_key = implode(':', $this->configFactory->getCacheKeys());
$config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys());
foreach ($entities as $id => $entity) {
$this->entities[$id][$config_overrides_key] = $entity;
}
......@@ -422,21 +429,17 @@ public function updateFromStorageRecord(ConfigEntityInterface $entity, array $va
* {@inheritdoc}
*/
public function loadOverrideFree($id) {
$old_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
$entity = $this->load($id);
$this->configFactory->setOverrideState($old_state);
return $entity;
$entities = $this->loadMultipleOverrideFree([$id]);
return isset($entities[$id]) ? $entities[$id] : NULL;
}
/**
* {@inheritdoc}
*/
public function loadMultipleOverrideFree(array $ids = NULL) {
$old_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
$this->overrideFree = TRUE;
$entities = $this->loadMultiple($ids);
$this->configFactory->setOverrideState($old_state);
$this->overrideFree = FALSE;
return $entities;
}
......
......@@ -73,11 +73,6 @@ public function alter(ContainerBuilder $container) {
$twig_config['cache'] = FALSE;
$container->setParameter('twig.config', $twig_config);
// Disable configuration overrides.
// ConfigFactory would to try to load language overrides and InstallStorage
// throws an exception upon trying to load a non-existing file.
$container->get('config.factory')->setOverrideState(FALSE);
// No service may persist when the early installer kernel is rebooted into
// the production environment.
// @todo The DrupalKernel reboot performed by drupal_install_system() is
......
......@@ -78,11 +78,7 @@ public function convert($value, $definition, $name, array $defaults) {
if ($storage = $this->entityManager->getStorage($entity_type_id)) {
// Make sure no overrides are loaded.
$old_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
$entity = $storage->load($value);
$this->configFactory->setOverrideState($old_state);
return $entity;
return $storage->loadOverrideFree($value);
}
}
......
......@@ -74,9 +74,7 @@ function testCRUD() {
$this->assertIdentical($config->isNew(), FALSE);
// Pollute the config factory static cache.
$config_factory->setOverrideState(FALSE);
$config_factory->get($name);
$config_factory->setOverrideState(TRUE);
$config_factory->getEditable($name);
// Delete the configuration object.
$config->delete();
......@@ -87,9 +85,7 @@ function testCRUD() {
// Verify that all copies of the configuration has been removed from the
// static cache.
$config_factory->setOverrideState(FALSE);
$this->assertIdentical($config_factory->get($name)->isNew(), TRUE);
$config_factory->setOverrideState(TRUE);
$this->assertIdentical($config_factory->getEditable($name)->isNew(), TRUE);
// Verify the active configuration contains no value.
$actual_data = $storage->read($name);
......@@ -130,11 +126,9 @@ function testCRUD() {
// Test renaming when config.factory does not have the object in its static
// cache.
$name = 'config_test.crud_rename';
// Turn off overrides and pollute the non-overrides static cache.
$config_factory->setOverrideState(FALSE);
$config_factory->get($name);
// Turn on overrides and pollute the overrides static cache.
$config_factory->setOverrideState(TRUE);
// Pollute the non-overrides static cache.
$config_factory->getEditable($name);
// Pollute the overrides static cache.
$config = $config_factory->get($name);
// Rename and ensure that happened properly.
$new_name = 'config_test.crud_rename_no_cache';
......@@ -145,9 +139,7 @@ function testCRUD() {
// Ensure the overrides static cache has been cleared.
$this->assertIdentical($config_factory->get($name)->isNew(), TRUE);
// Ensure the non-overrides static cache has been cleared.
$config_factory->setOverrideState(FALSE);
$this->assertIdentical($config_factory->get($name)->isNew(), TRUE);
$config_factory->setOverrideState(TRUE);
$this->assertIdentical($config_factory->getEditable($name)->isNew(), TRUE);
// Merge data into the configuration object.
$new_config = $this->config($new_name);
......
......@@ -83,28 +83,28 @@ public function testReset() {
* Tests that the static cache is sensitive to config overrides.
*/
public function testConfigOverride() {
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorage $storage */
$storage = \Drupal::entityManager()->getStorage($this->entityTypeId);
// Prime the cache prior to adding a config override.
entity_load($this->entityTypeId, $this->entityId);
$storage->load($this->entityId);
// Add the config override, and ensure that what is loaded is correct
// despite the prior cache priming.
\Drupal::configFactory()->addOverride(new ConfigOverrider());
$entity_override = entity_load($this->entityTypeId, $this->entityId);
$entity_override = $storage->load($this->entityId);
$this->assertIdentical($entity_override->label, 'Overridden label');
// Disable overrides to ensure that loading the config entity again does not
// return the overridden value.
\Drupal::configFactory()->setOverrideState(FALSE);
$entity_no_override = entity_load($this->entityTypeId, $this->entityId);
// Load override free to ensure that loading the config entity again does
// not return the overridden value.
$entity_no_override = $storage->loadOverrideFree($this->entityId);
$this->assertNotIdentical($entity_no_override->label, 'Overridden label');
$this->assertNotIdentical($entity_override->_loadStamp, $entity_no_override->_loadStamp);
// Reload the entity and ensure the cache is used.
$this->assertIdentical(entity_load($this->entityTypeId, $this->entityId)->_loadStamp, $entity_no_override->_loadStamp);
$this->assertIdentical($storage->loadOverrideFree($this->entityId)->_loadStamp, $entity_no_override->_loadStamp);
// Enable overrides and reload the entity and ensure the cache is used.
\Drupal::configFactory()->setOverrideState(TRUE);
$this->assertIdentical(entity_load($this->entityTypeId, $this->entityId)->_loadStamp, $entity_override->_loadStamp);
$this->assertIdentical($storage->load($this->entityId)->_loadStamp, $entity_override->_loadStamp);
}
}
......@@ -31,7 +31,6 @@ public function testFormsWithOverrides() {
'required' => TRUE,
);
$this->writeSettings($settings);
\Drupal::configFactory()->setOverrideState(TRUE);
// Test that everything on the form is the same, but that the override
// worked for the actual site name.
......
......@@ -68,11 +68,7 @@ function testConfigLanguageOverride() {
$config = \Drupal::config('config_test.new');
$this->assertTrue($config->isNew(), 'The configuration object config_test.new is new');
$this->assertIdentical($config->get('language'), 'override');
$old_state = \Drupal::configFactory()->getOverrideState();
\Drupal::configFactory()->setOverrideState(FALSE);
$config = \Drupal::config('config_test.new');
$this->assertIdentical($config->get('language'), NULL);
\Drupal::configFactory()->setOverrideState($old_state);
$this->assertIdentical($config->getOriginal('language', FALSE), NULL);
// Test how overrides react to base configuration changes. Set up some base
// values.
......
......@@ -37,17 +37,8 @@ public function testSimpleModuleOverrides() {
->set('slogan', $non_overridden_slogan)
->save();
$this->assertTrue($config_factory->getOverrideState(), 'By default ConfigFactory has overrides enabled.');
$old_state = $config_factory->getOverrideState();
$config_factory->setOverrideState(FALSE);
$this->assertFalse($config_factory->getOverrideState(), 'ConfigFactory can disable overrides.');
$this->assertEqual($non_overridden_name, $config_factory->get('system.site')->get('name'));
$this->assertEqual($non_overridden_slogan, $config_factory->get('system.site')->get('slogan'));
$config_factory->setOverrideState(TRUE);
$this->assertTrue($config_factory->getOverrideState(), 'ConfigFactory can enable overrides.');
$this->assertEqual($non_overridden_name, $config_factory->get('system.site')->getOriginal('name', FALSE));
$this->assertEqual($non_overridden_slogan, $config_factory->get('system.site')->getOriginal('slogan', FALSE));
$this->assertEqual($overridden_name, $config_factory->get('system.site')->get('name'));
$this->assertEqual($overridden_slogan, $config_factory->get('system.site')->get('slogan'));
......@@ -57,11 +48,8 @@ public function testSimpleModuleOverrides() {
$config = $config_factory->get('config_override_test.new');
$this->assertTrue($config->isNew(), 'The configuration object config_override_test.new is new');
$this->assertIdentical($config->get('module'), 'override');
$config_factory->setOverrideState(FALSE);
$config = $this->config('config_override_test.new');
$this->assertIdentical($config->get('module'), NULL);
$this->assertIdentical($config->getOriginal('module', FALSE), NULL);
$config_factory->setOverrideState($old_state);
unset($GLOBALS['config_test_run_module_overrides']);
}
}
......@@ -124,15 +124,12 @@ function testConfOverride() {
$config = \Drupal::config('config_test.new');
$this->assertTrue($config->isNew(), 'The configuration object config_test.new is new');
$this->assertIdentical($config->get('key'), 'override');
$old_state = \Drupal::configFactory()->getOverrideState();
\Drupal::configFactory()->setOverrideState(FALSE);
$config_raw = \Drupal::configFactory()->getEditable('config_test.new');
$this->assertIdentical($config_raw->get('key'), NULL);
$config_raw
->set('key', 'raw')
->set('new_key', 'new_value')
->save();
\Drupal::configFactory()->setOverrideState($old_state);
// Ensure override is preserved but all other data has been updated
// accordingly.
$this->assertIdentical($config->get('key'), 'override');
......
......@@ -90,13 +90,10 @@ public function testOverridePriorities() {
$this->assertEqual($language_overridden_mail, $config_factory->get('system.site')->get('mail'));
$this->assertEqual(50, $config_factory->get('system.site')->get('weight_select_max'));
$old_state = $config_factory->getOverrideState();
$config_factory->setOverrideState(FALSE);
$this->assertEqual($non_overridden_name, $config_factory->get('system.site')->get('name'));
$this->assertEqual($non_overridden_slogan, $config_factory->get('system.site')->get('slogan'));
$this->assertEqual($non_overridden_mail, $config_factory->get('system.site')->get('mail'));
$this->assertEqual(50, $config_factory->get('system.site')->get('weight_select_max'));
$config_factory->setOverrideState($old_state);
$this->assertEqual($non_overridden_name, $config_factory->get('system.site')->getOriginal('name', FALSE));
$this->assertEqual($non_overridden_slogan, $config_factory->get('system.site')->getOriginal('slogan', FALSE));
$this->assertEqual($non_overridden_mail, $config_factory->get('system.site')->getOriginal('mail', FALSE));
$this->assertEqual(50, $config_factory->get('system.site')->getOriginal('weight_select_max', FALSE));
unset($GLOBALS['config_test_run_module_overrides']);
}
......
......@@ -431,7 +431,7 @@ public function getLanguageWithFallback() {
public function getConfigData() {
$config_data = array();
foreach ($this->getConfigNames() as $name) {
$config_data[$name] = $this->configFactory->get($name)->get();
$config_data[$name] = $this->configFactory->getEditable($name)->get();
}
return $config_data;
}
......
......@@ -148,11 +148,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
// Get base language configuration to display in the form before setting the
// language to use for the form. This avoids repetitively settings and
// resetting the language to get original values later.
$config_factory = $this->configFactory();
$old_state = $config_factory->getOverrideState();
$config_factory->setOverrideState(FALSE);
$this->baseConfigData = $this->mapper->getConfigData();
$config_factory->setOverrideState($old_state);
// Set the translation target language on the configuration factory.
$original_language = $this->languageManager->getConfigOverrideLanguage();
......@@ -174,7 +170,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
$schema = $this->typedConfigManager->get($name);
$source_config = $this->baseConfigData[$name];
$translation_config = $config_factory->get($name)->get();
$translation_config = $this->configFactory()->get($name)->get();
if ($form_element = $this->createFormElement($schema)) {
$parents = array('config_names', $name);
......@@ -201,16 +197,11 @@ public function buildForm(array $form, FormStateInterface $form_state, Request $
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_values = $form_state->getValue(array('translation', 'config_names'));
// For the form submission handling, use the raw data.
$config_factory = $this->configFactory();
$old_state = $config_factory->getOverrideState();
$config_factory->setOverrideState(FALSE);
foreach ($this->mapper->getConfigNames() as $name) {
$schema = $this->typedConfigManager->get($name);
// Set configuration values based on form submission and source values.
$base_config = $config_factory->get($name);
$base_config = $this->configFactory()->getEditable($name);
$config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name);
$element = $this->createFormElement($schema);
......@@ -225,7 +216,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$config_translation->save();
}
}
$config_factory->setOverrideState($old_state);
$form_state->setRedirect(
$this->mapper->getOverviewRoute(),
......
......@@ -715,9 +715,8 @@ public function testTextFormatTranslation() {
'format' => 'plain_text',
);
$actual = $config_factory
->setOverrideState(FALSE)
->get('config_translation_test.content')
->get('content');
->getOriginal('content', FALSE);
$this->assertEqual($expected, $actual);
$translation_base_url = 'admin/config/media/file-system/translate';
......@@ -749,7 +748,6 @@ public function testTextFormatTranslation() {
$this->container->get('language.config_factory_override')
->setLanguage(new Language(array('id' => 'fr')));
$actual = $config_factory
->setOverrideState(TRUE)
->get('config_translation_test.content')
->get('content');
$this->assertEqual($expected, $actual);
......@@ -758,13 +756,11 @@ public function testTextFormatTranslation() {
// text format of the translation does not change because that could lead to
// security vulnerabilities.
$config_factory
->setOverrideState(FALSE)
->getEditable('config_translation_test.content')
->set('content.format', 'full_html')
->save();
$actual = $config_factory
->setOverrideState(TRUE)
->get('config_translation_test.content')
->get('content');
// The translation should not have changed, so re-use $expected.
......
......@@ -128,15 +128,9 @@ protected function updateTranslationStrings(LanguageConfigOverrideCrudEvent $eve
// Only do anything if the configuration was shipped.
if ($this->stringStorage->getLocations(['type' => 'configuration', 'name' => $name])) {
$override_state = $this->configFactory->getOverrideState();
$this->configFactory->setOverrideState(FALSE);
$source_config = $this->configFactory->get($name);
$source_config = $this->configFactory->getEditable($name);
$schema = $this->localeConfigManager->get($name)->getTypedConfig();
$this->traverseSchema($schema, $source_config, $translation_config, $callable);
$this->configFactory->setOverrideState($override_state);
}
}
......
......@@ -330,11 +330,7 @@ protected function deleteLocaleTranslationData($config_name, $key, $source_value
protected function assertConfigValue($config_name, $key, $value) {
// Make sure the configuration was translated correctly.
$translation_config = $this->configFactory->get($config_name);
$passed = $this->assertIdentical($value, $translation_config->get($key));
// Make sure the override state of the configuration factory was not
// modified.
return $passed && $this->assertIdentical(TRUE, $this->configFactory->getOverrideState());
return $this->assertIdentical($value, $translation_config->get($key));
}
/**
......
......@@ -36,12 +36,9 @@ protected function setUp() {
* Tests migration of system (file) variables to system.file.yml.
*/
public function testSystemFile() {
$old_state = \Drupal::configFactory()->getOverrideState();
\Drupal::configFactory()->setOverrideState(FALSE);
$config = $this->config('system.file');
$config = \Drupal::configFactory()->getEditable('system.file');
$this->assertIdentical($config->get('path.temporary'), 'files/temp');
$this->assertIdentical($config->get('allow_insecure_uploads'), TRUE);
\Drupal::configFactory()->setOverrideState($old_state);
}
}
......@@ -12,6 +12,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\ConfigFormBaseTrait;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
......@@ -23,6 +24,7 @@
* @see \Drupal\search\Entity\SearchPage
*/
class SearchPageListBuilder extends DraggableListBuilder implements FormInterface {
use ConfigFormBaseTrait;
/**
* The entities being listed.
......@@ -82,6 +84,13 @@ public function getFormID() {
return 'search_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return ['search.settings'];
}
/**
* {@inheritdoc}
*/
......@@ -156,9 +165,7 @@ public function buildRow(EntityInterface $entity) {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$old_state = $this->configFactory->getOverrideState();
$search_settings = $this->configFactory->setOverrideState(FALSE)->get('search.settings');
$this->configFactory->setOverrideState($old_state);
$search_settings = $this->config('search.settings');
// Collect some stats.
$remaining = 0;
$total = 0;
......@@ -328,7 +335,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$search_settings = $this->configFactory->getEditable('search.settings');
$search_settings = $this->config('search.settings');
// If these settings change, the default index needs to be rebuilt.
if (($search_settings->get('index.minimum_word_size') != $form_state->getValue('minimum_word_size')) || ($search_settings->get('index.overlap_cjk') != $form_state->getValue('overlap_cjk'))) {
$search_settings->set('index.minimum_word_size', $form_state->getValue('minimum_word_size'));
......
......@@ -1626,12 +1626,7 @@ public function copyConfig(StorageInterface $source_storage, StorageInterface $t
* The configuration object with original configuration data.
*/
protected function config($name) {
$config_factory = \Drupal::configFactory();
$old_state = $config_factory->getOverrideState();
$config_factory->setOverrideState(FALSE);
$config = $config_factory->getEditable($name);
$config_factory->setOverrideState($old_state);
return $config;
return \Drupal::configFactory()->getEditable($name);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment