diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php index 8d971dc..8ed7403 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php @@ -17,20 +17,13 @@ abstract class ConfigFormBase extends FormBase { /** - * Stores the configuration factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * Constructs a \Drupal\system\ConfigFormBase object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. */ public function __construct(ConfigFactoryInterface $config_factory) { - $this->configFactory = $config_factory; + $this->setConfigFactory($config_factory); } /** @@ -74,10 +67,12 @@ public function submitForm(array &$form, array &$form_state) { * configuration. */ protected function config($name) { - $old_state = $this->configFactory->getOverrideState(); - $this->configFactory->setOverrideState(FALSE); - $config = $this->configFactory->get($name); - $this->configFactory->setOverrideState($old_state); + $config_factory = $this->configFactory(); + $old_state = $config_factory->getOverrideState(); + $config_factory->setOverrideState(FALSE); + $config = $config_factory->get($name); + $config_factory->setOverrideState($old_state); return $config; } + } diff --git a/core/lib/Drupal/Core/Form/FormBase.php b/core/lib/Drupal/Core/Form/FormBase.php index 93abb5b..8a4009f 100644 --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -44,9 +44,14 @@ /** * The config factory. * + * This is marked private in order to force subclasses to use the + * self::config() method, which may be overridden to address specific needs + * when loading config. See \Drupal\Core\Form\ConfigFormBase::config() for an + * example of this. + * * @var \Drupal\Core\Config\ConfigFactoryInterface */ - protected $configFactory; + private $configFactory; /** * The form error handler. @@ -121,10 +126,22 @@ protected function translationManager() { * A configuration object. */ protected function config($name) { + return $this->configFactory()->get($name); + } + + /** + * Gets the config factory for this form. + * + * When accessing configuration values, use $this->config(). Only use this + * when the config factory needs to be manipulated directly. + * + * @return \Drupal\Core\Config\ConfigFactoryInterface + */ + protected function configFactory() { if (!$this->configFactory) { $this->configFactory = $this->container()->get('config.factory'); } - return $this->configFactory->get($name); + return $this->configFactory; } /** diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php index 29376bc..2d8ebb3 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php @@ -99,7 +99,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('aggregator.settings'); + $config = $this->config('aggregator.settings'); // Global aggregator settings. $form['aggregator_allowed_html_tags'] = array( @@ -200,7 +200,7 @@ public function validateForm(array &$form, array &$form_state) { */ public function submitForm(array &$form, array &$form_state) { parent::submitForm($form, $form_state); - $config = $this->configFactory->get('aggregator.settings'); + $config = $this->config('aggregator.settings'); // Let active plugins save their settings. foreach ($this->configurableInstances as $instance) { $instance->submitConfigurationForm($form, $form_state); diff --git a/core/modules/block/lib/Drupal/block/BlockForm.php b/core/modules/block/lib/Drupal/block/BlockForm.php index 350fde6..d614dce 100644 --- a/core/modules/block/lib/Drupal/block/BlockForm.php +++ b/core/modules/block/lib/Drupal/block/BlockForm.php @@ -8,7 +8,6 @@ namespace Drupal\block; use Drupal\Core\Cache\Cache; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; @@ -43,26 +42,16 @@ class BlockForm extends EntityForm { protected $languageManager; /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * Constructs a BlockForm object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. */ - public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory) { + public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) { $this->storage = $entity_manager->getStorage('block'); $this->languageManager = $language_manager; - $this->configFactory = $config_factory; } /** @@ -71,8 +60,7 @@ public function __construct(EntityManagerInterface $entity_manager, LanguageMana public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), - $container->get('language_manager'), - $container->get('config.factory') + $container->get('language_manager') ); } @@ -84,7 +72,7 @@ public function form(array $form, array &$form_state) { // Store theme settings in $form_state for use below. if (!$theme = $entity->get('theme')) { - $theme = $this->configFactory->get('system.theme')->get('default'); + $theme = $this->config('system.theme')->get('default'); } $form_state['block_theme'] = $theme; diff --git a/core/modules/book/lib/Drupal/book/Form/BookSettingsForm.php b/core/modules/book/lib/Drupal/book/Form/BookSettingsForm.php index 499b70e..140f8e5 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookSettingsForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookSettingsForm.php @@ -26,7 +26,7 @@ public function getFormId() { */ public function buildForm(array $form, array &$form_state) { $types = node_type_get_names(); - $config = $this->configFactory->get('book.settings'); + $config = $this->config('book.settings'); $form['book_allowed_types'] = array( '#type' => 'checkboxes', '#title' => $this->t('Content types allowed in book outlines'), @@ -68,7 +68,7 @@ public function submitForm(array &$form, array &$form_state) { // that we can save them in the correct order if node type changes. // @see book_node_type_update(). sort($allowed_types); - $this->configFactory->get('book.settings') + $this->config('book.settings') // Remove unchecked types. ->set('allowed_types', $allowed_types) ->set('child_type', $form_state['values']['book_child_type']) diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFormOverrideTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFormOverrideTest.php new file mode 100644 index 0000000..5a22e90 --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFormOverrideTest.php @@ -0,0 +1,61 @@ + 'Config form overrides', + 'description' => 'Tests that config overrides do not bleed through in forms.', + 'group' => 'Configuration', + ); + } + + /** + * Tests that overrides do not affect forms. + */ + public function testFormsWithOverrides() { + $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + + $overridden_name = 'Site name global conf override'; + + // Set up an override. + $settings['config']['system.site']['name'] = (object) array( + 'value' => $overridden_name, + '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. + $this->drupalGet('admin/config/system/site-information'); + $this->assertTitle('Site information | ' . $overridden_name); + $elements = $this->xpath('//input[@name="site_name"]'); + $this->assertIdentical((string) $elements[0]['value'], 'Drupal'); + + // Submit the form and ensure the site name is not changed. + $edit = array( + 'site_name' => 'Custom site name', + ); + $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); + $this->assertTitle('Site information | ' . $overridden_name); + $elements = $this->xpath('//input[@name="site_name"]'); + $this->assertIdentical((string) $elements[0]['value'], $edit['site_name']); + } + +} diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php index 4d2bd68..fb3ba88 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Form/ConfigTranslationFormBase.php @@ -9,7 +9,6 @@ use Drupal\config_translation\ConfigMapperManagerInterface; use Drupal\Core\Config\Config; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\Schema\Element; use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -101,15 +100,12 @@ * The translation storage object. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke the alter hook. - * @param \Drupal\Core\Config\ConfigFactoryInterface - * The config factory. */ - public function __construct(TypedConfigManager $typed_config_manager, ConfigMapperManagerInterface $config_mapper_manager, StringStorageInterface $locale_storage, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager) { + public function __construct(TypedConfigManager $typed_config_manager, ConfigMapperManagerInterface $config_mapper_manager, StringStorageInterface $locale_storage, ModuleHandlerInterface $module_handler, ConfigurableLanguageManagerInterface $language_manager) { $this->typedConfigManager = $typed_config_manager; $this->configMapperManager = $config_mapper_manager; $this->localeStorage = $locale_storage; $this->moduleHandler = $module_handler; - $this->configFactory = $config_factory; $this->languageManager = $language_manager; } @@ -122,7 +118,6 @@ public static function create(ContainerInterface $container) { $container->get('plugin.manager.config_translation.mapper'), $container->get('locale.storage'), $container->get('module_handler'), - $container->get('config.factory'), $container->get('language_manager') ); } @@ -176,10 +171,11 @@ public function buildForm(array $form, array &$form_state, Request $request = NU // 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. - $old_state = $this->configFactory->getOverrideState(); - $this->configFactory->setOverrideState(FALSE); + $config_factory = $this->configFactory(); + $old_state = $config_factory->getOverrideState(); + $config_factory->setOverrideState(FALSE); $this->baseConfigData = $this->mapper->getConfigData(); - $this->configFactory->setOverrideState($old_state); + $config_factory->setOverrideState($old_state); // Set the translation target language on the configuration factory. $original_language = $this->languageManager->getConfigOverrideLanguage(); @@ -198,7 +194,7 @@ public function buildForm(array $form, array &$form_state, Request $request = NU ); foreach ($this->mapper->getConfigNames() as $name) { $form['config_names'][$name] = array('#type' => 'container'); - $form['config_names'][$name] += $this->buildConfigForm($this->typedConfigManager->get($name), $this->config($name)->get(), $this->baseConfigData[$name]); + $form['config_names'][$name] += $this->buildConfigForm($this->typedConfigManager->get($name), $config_factory->get($name)->get(), $this->baseConfigData[$name]); } $form['actions']['#type'] = 'actions'; @@ -221,12 +217,13 @@ public function submitForm(array &$form, array &$form_state) { $form_values = $form_state['values']['config_names']; // For the form submission handling, use the raw data. - $old_state = $this->configFactory->getOverrideState(); - $this->configFactory->setOverrideState(FALSE); + $config_factory = $this->configFactory(); + $old_state = $config_factory->getOverrideState(); + $config_factory->setOverrideState(FALSE); foreach ($this->mapper->getConfigNames() as $name) { // Set configuration values based on form submission and source values. - $base_config = $this->config($name); + $base_config = $config_factory->get($name); $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->id, $name); $locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $name)); @@ -241,7 +238,7 @@ public function submitForm(array &$form, array &$form_state) { $config_translation->save(); } } - $this->configFactory->setOverrideState($old_state); + $config_factory->setOverrideState($old_state); $form_state['redirect_route'] = array( 'route_name' => $this->mapper->getOverviewRoute(), diff --git a/core/modules/contact/lib/Drupal/contact/MessageForm.php b/core/modules/contact/lib/Drupal/contact/MessageForm.php index d28a8cb..4519db7 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageForm.php +++ b/core/modules/contact/lib/Drupal/contact/MessageForm.php @@ -8,7 +8,6 @@ namespace Drupal\contact; use Drupal\Component\Utility\String; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\ContentEntityForm; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Flood\FloodInterface; @@ -29,13 +28,6 @@ class MessageForm extends ContentEntityForm { protected $entity; /** - * The config factory service. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * The flood control mechanism. * * @var \Drupal\Core\Flood\FloodInterface @@ -45,17 +37,14 @@ class MessageForm extends ContentEntityForm { /** * Constructs a MessageForm object. * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The factory for configuration objects. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. * @param \Drupal\Core\Flood\FloodInterface $flood * The flood control mechanism. */ - public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, FloodInterface $flood) { + public function __construct(EntityManagerInterface $entity_manager, FloodInterface $flood) { parent::__construct($entity_manager); - $this->configFactory = $config_factory; $this->flood = $flood; } @@ -64,7 +53,6 @@ public function __construct(ConfigFactoryInterface $config_factory, EntityManage */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.factory'), $container->get('entity.manager'), $container->get('flood') ); @@ -241,7 +229,7 @@ public function save(array $form, array &$form_state) { drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params); } - $config = $this->configFactory->get('contact.settings'); + $config = $this->config('contact.settings'); $this->flood->register('contact', $config->get('flood.interval')); if (!$message->isPersonal()) { watchdog('contact', '%sender-name (@sender-from) sent an e-mail regarding %category.', array( diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php index 2f986ff..28d2758 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormBase.php @@ -19,13 +19,6 @@ abstract class FilterFormatFormBase extends EntityForm { /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * The entity query factory. * * @var \Drupal\Core\Entity\Query\QueryFactory @@ -35,13 +28,10 @@ /** * Constructs a new FilterFormatFormBase. * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. */ - public function __construct(ConfigFactoryInterface $config_factory, QueryFactory $query_factory) { - $this->configFactory = $config_factory; + public function __construct(QueryFactory $query_factory) { $this->queryFactory = $query_factory; } @@ -50,7 +40,6 @@ public function __construct(ConfigFactoryInterface $config_factory, QueryFactory */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.factory'), $container->get('entity.query') ); } @@ -60,7 +49,7 @@ public static function create(ContainerInterface $container) { */ public function form(array $form, array &$form_state) { $format = $this->entity; - $is_fallback = ($format->id() == $this->configFactory->get('filter.settings')->get('fallback_format')); + $is_fallback = ($format->id() == $this->config('filter.settings')->get('fallback_format')); $form['#tree'] = TRUE; $form['#attached']['library'][] = 'filter/drupal.filter.admin'; @@ -100,7 +89,7 @@ public function form(array $form, array &$form_state) { // If editing an existing text format, pre-select its current permissions. $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format)); } - elseif ($admin_role = $this->configFactory->get('user.settings')->get('admin_role')) { + elseif ($admin_role = $this->config('user.settings')->get('admin_role')) { // If adding a new text format and the site has an administrative role, // pre-select that role so as to grant administrators access to the new // text format permission by default. diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumForm.php b/core/modules/forum/lib/Drupal/forum/Form/ForumForm.php index 2a4c69a..3592001 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumForm.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumForm.php @@ -139,7 +139,7 @@ protected function forumParentSelect($tid, $title) { $parent = 0; } - $vid = $this->configFactory->get('forum.settings')->get('vocabulary'); + $vid = $this->config('forum.settings')->get('vocabulary'); // @todo Inject a taxonomy service when one exists. $children = taxonomy_get_tree($vid, $tid, NULL, TRUE); diff --git a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php index 055516f..dbe486f 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php +++ b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php @@ -25,7 +25,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('forum.settings'); + $config = $this->config('forum.settings'); $options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500); $form['forum_hot_topic'] = array( @@ -64,7 +64,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('forum.settings') + $this->config('forum.settings') ->set('topics.hot_threshold', $form_state['values']['forum_hot_topic']) ->set('topics.page_limit', $form_state['values']['forum_per_page']) ->set('topics.order', $form_state['values']['forum_order']) diff --git a/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php b/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php index c1c0381..c3010ba 100644 --- a/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php +++ b/core/modules/language/lib/Drupal/language/Form/ContentLanguageSettingsForm.php @@ -160,7 +160,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $config = $this->configFactory->get('language.settings'); + $config = $this->config('language.settings'); foreach ($form_state['values']['settings'] as $entity_type => $entity_settings) { foreach ($entity_settings as $bundle => $bundle_settings) { $config->set(language_get_default_configuration_settings_key($entity_type, $bundle), diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php index 8bbf247..a23faf0 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php @@ -171,7 +171,7 @@ public function validateForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) { $mappings = $form_state['mappings']; if (!empty($mappings)) { - $config = $this->configFactory->get('language.mappings'); + $config = $this->config('language.mappings'); $config->setData($mappings); $config->save(); } @@ -187,7 +187,7 @@ public function submitForm(array &$form, array &$form_state) { * The browser's langcode mapping configuration array. */ protected function language_get_browser_drupal_langcode_mappings() { - $config = $this->configFactory->get('language.mappings'); + $config = $this->config('language.mappings'); if ($config->isNew()) { return array(); } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php index 614fd3b..14c13f4 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationSelectedForm.php @@ -26,7 +26,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('language.negotiation'); + $config = $this->config('language.negotiation'); $form['selected_langcode'] = array( '#type' => 'language_select', '#title' => t('Language'), @@ -41,7 +41,7 @@ public function buildForm(array $form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('language.negotiation') + $this->config('language.negotiation') ->set('selected_langcode', $form_state['values']['selected_langcode']) ->save(); diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php index b688b05..13936af 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php @@ -25,7 +25,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('language.negotiation'); + $config = $this->config('language.negotiation'); $form['language_negotiation_session_param'] = array( '#title' => t('Request/session parameter'), '#type' => 'textfield', @@ -42,7 +42,7 @@ public function buildForm(array $form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('language.settings') + $this->config('language.settings') ->set('session.parameter', $form_state['values']['language_negotiation_session_param']) ->save(); diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php index 6f9cdf5..d8c2490 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php @@ -27,7 +27,7 @@ public function getFormId() { */ public function buildForm(array $form, array &$form_state) { global $base_url; - $config = $this->configFactory->get('language.negotiation'); + $config = $this->config('language.negotiation'); $form['language_negotiation_url_part'] = array( '#title' => t('Part of the URL that determines language'), @@ -162,7 +162,7 @@ public function validateForm(array &$form, array &$form_state) { */ public function submitForm(array &$form, array &$form_state) { // Save selected format (prefix or domain). - $this->configFactory->get('language.negotiation') + $this->config('language.negotiation') ->set('url.source', $form_state['values']['language_negotiation_url_part']) ->save(); diff --git a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php index 6ed3195..5bc2968 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php @@ -24,7 +24,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('locale.settings'); + $config = $this->config('locale.settings'); $form['update_interval_days'] = array( '#type' => 'radios', @@ -97,7 +97,7 @@ public function validateForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) { $values = $form_state['values']; - $config = $this->configFactory->get('locale.settings'); + $config = $this->config('locale.settings'); $config->set('translation.update_interval_days', $values['update_interval_days'])->save(); $config->set('translation.use_source', $values['use_source'])->save(); diff --git a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuSettingsForm.php b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuSettingsForm.php index d996a81..73bc7d7 100644 --- a/core/modules/menu_ui/lib/Drupal/menu_ui/MenuSettingsForm.php +++ b/core/modules/menu_ui/lib/Drupal/menu_ui/MenuSettingsForm.php @@ -25,7 +25,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('menu_ui.settings'); + $config = $this->config('menu_ui.settings'); $form['intro'] = array( '#type' => 'item', '#markup' => t('The Menu UI module allows on-the-fly creation of menu links in the content authoring forms. To configure these settings for a particular content type, visit the Content types page, click the edit link for the content type, and go to the Menu settings section.', array('@content-types' => url('admin/structure/types'))), @@ -61,7 +61,7 @@ public function buildForm(array $form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('menu_ui.settings') + $this->config('menu_ui.settings') ->set('main_links', $form_state['values']['menu_main_links_source']) ->set('secondary_links', $form_state['values']['menu_secondary_links_source']) ->save(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php index dfd80a1..563b05d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestSettingsForm.php @@ -25,7 +25,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('simpletest.settings'); + $config = $this->config('simpletest.settings'); $form['general'] = array( '#type' => 'details', '#title' => $this->t('General'), @@ -87,7 +87,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function validateForm(array &$form, array &$form_state) { - $config = $this->configFactory->get('simpletest.settings'); + $config = $this->config('simpletest.settings'); // If a username was provided but a password wasn't, preserve the existing // password. if (!empty($form_state['values']['simpletest_httpauth_username']) && empty($form_state['values']['simpletest_httpauth_password'])) { @@ -107,7 +107,7 @@ public function validateForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('simpletest.settings') + $this->config('simpletest.settings') ->set('clear_results', $form_state['values']['simpletest_clear_results']) ->set('verbose', $form_state['values']['simpletest_verbose']) ->set('httpauth.method', $form_state['values']['simpletest_httpauth_method']) diff --git a/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php b/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php index d4683a9..4b7f362 100644 --- a/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php +++ b/core/modules/statistics/lib/Drupal/statistics/StatisticsSettingsForm.php @@ -58,7 +58,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('statistics.settings'); + $config = $this->config('statistics.settings'); // Content counter settings. $form['content'] = array( @@ -80,7 +80,7 @@ public function buildForm(array $form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('statistics.settings') + $this->config('statistics.settings') ->set('count_content_views', $form_state['values']['statistics_count_content_views']) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php index 8a27db2..43a3013 100644 --- a/core/modules/system/lib/Drupal/system/Form/CronForm.php +++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php @@ -71,7 +71,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('system.cron'); + $config = $this->config('system.cron'); $form['description'] = array( '#markup' => '

' . t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.') . '

', @@ -112,7 +112,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.cron') + $this->config('system.cron') ->set('threshold.autorun', $form_state['values']['cron_safe_threshold']) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php index 4f5a4ee..281bab5 100644 --- a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php +++ b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php @@ -26,7 +26,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('system.file'); + $config = $this->config('system.file'); $form['file_public_path'] = array( '#type' => 'item', '#title' => t('Public file system path'), @@ -86,7 +86,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $config = $this->configFactory->get('system.file') + $config = $this->config('system.file') ->set('path.private', $form_state['values']['file_private_path']) ->set('path.temporary', $form_state['values']['file_temporary_path']) ->set('temporary_maximum_age', $form_state['values']['temporary_maximum_age']); diff --git a/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php index e28e647..be00cd8 100644 --- a/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ImageToolkitForm.php @@ -61,7 +61,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $current_toolkit = $this->configFactory->get('system.image')->get('toolkit'); + $current_toolkit = $this->config('system.image')->get('toolkit'); $form['image_toolkit'] = array( '#type' => 'radios', @@ -96,7 +96,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.image') + $this->config('system.image') ->set('toolkit', $form_state['values']['image_toolkit']) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php index 71b7260..f52fc6a 100644 --- a/core/modules/system/lib/Drupal/system/Form/LoggingForm.php +++ b/core/modules/system/lib/Drupal/system/Form/LoggingForm.php @@ -25,7 +25,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('system.logging'); + $config = $this->config('system.logging'); $form['error_level'] = array( '#type' => 'radios', '#title' => t('Error messages to display'), @@ -46,7 +46,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.logging') + $this->config('system.logging') ->set('error_level', $form_state['values']['error_level']) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php index 2fb139a..fbc60bc 100644 --- a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php +++ b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php @@ -60,7 +60,7 @@ public function getFormId() { public function buildForm(array $form, array &$form_state) { $form['#attached']['library'][] = 'system/drupal.system'; - $config = $this->configFactory->get('system.performance'); + $config = $this->config('system.performance'); $form['clear_cache'] = array( '#type' => 'details', @@ -152,7 +152,7 @@ public function submitForm(array &$form, array &$form_state) { // form submit. $this->renderCache->deleteAll(); - $this->configFactory->get('system.performance') + $this->config('system.performance') ->set('cache.page.use_internal', $form_state['values']['cache']) ->set('cache.page.max_age', $form_state['values']['page_cache_maximum_age']) ->set('response.gzip', $form_state['values']['page_compression']) diff --git a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php index bf4ebaf..d361859 100644 --- a/core/modules/system/lib/Drupal/system/Form/RegionalForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RegionalForm.php @@ -59,7 +59,7 @@ public function getFormId() { */ public function buildForm(array $form, array &$form_state) { $countries = $this->countryManager->getList(); - $system_date = $this->configFactory->get('system.date'); + $system_date = $this->config('system.date'); // Date settings: $zones = system_time_zones(); @@ -142,7 +142,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.date') + $this->config('system.date') ->set('country.default', $form_state['values']['site_default_country']) ->set('first_day', $form_state['values']['date_first_day']) ->set('timezone.default', $form_state['values']['date_default_timezone']) diff --git a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php index b18cdfe..4d8fe3a 100644 --- a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php +++ b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php @@ -25,7 +25,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $rss_config = $this->configFactory->get('system.rss'); + $rss_config = $this->config('system.rss'); $form['feed_description'] = array( '#type' => 'textarea', '#title' => t('Feed description'), @@ -59,7 +59,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.rss') + $this->config('system.rss') ->set('channel.description', $form_state['values']['feed_description']) ->set('items.limit', $form_state['values']['feed_default_items']) ->set('items.view_mode', $form_state['values']['feed_item_length']) diff --git a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php index 1a10aaa..b5d3f5e 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteInformationForm.php @@ -59,7 +59,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $site_config = $this->configFactory->get('system.site'); + $site_config = $this->config('system.site'); $site_mail = $site_config->get('mail'); if (empty($site_mail)) { $site_mail = ini_get('sendmail_from'); @@ -168,7 +168,7 @@ public function validateForm(array &$form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.site') + $this->config('system.site') ->set('name', $form_state['values']['site_name']) ->set('mail', $form_state['values']['site_mail']) ->set('slogan', $form_state['values']['site_slogan']) diff --git a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php index eff16a1..7de4e61 100644 --- a/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php +++ b/core/modules/system/lib/Drupal/system/Form/SiteMaintenanceModeForm.php @@ -57,7 +57,7 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('system.maintenance'); + $config = $this->config('system.maintenance'); $form['maintenance_mode'] = array( '#type' => 'checkbox', '#title' => t('Put site into maintenance mode'), @@ -77,7 +77,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('system.maintenance') + $this->config('system.maintenance') ->set('message', $form_state['values']['maintenance_mode_message']) ->save(); diff --git a/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php b/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php index ad3ceaa..0d4a10f 100644 --- a/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ThemeSettingsForm.php @@ -376,7 +376,7 @@ public function validateForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) { parent::submitForm($form, $form_state); - $config = $this->configFactory->get($form_state['values']['config_key']); + $config = $this->config($form_state['values']['config_key']); // Exclude unnecessary elements before saving. form_state_values_clean($form_state); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php index 8f01c40..e3b048a 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermForm.php @@ -8,11 +8,8 @@ namespace Drupal\taxonomy; use Drupal\Core\Cache\Cache; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\ContentEntityForm; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Language\Language; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base for controller for taxonomy term edit forms. @@ -20,36 +17,6 @@ class TermForm extends ContentEntityForm { /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** - * Constructs a new TermForm. - * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. - */ - public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory) { - parent::__construct($entity_manager); - $this->configFactory = $config_factory; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager'), - $container->get('config.factory') - ); - } - - /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { @@ -81,7 +48,7 @@ public function form(array $form, array &$form_state) { // numbers of items so we check for taxonomy.settings:override_selector // before loading the full vocabulary. Contrib modules can then intercept // before hook_form_alter to provide scalable alternatives. - if (!$this->configFactory->get('taxonomy.settings')->get('override_selector')) { + if (!$this->config('taxonomy.settings')->get('override_selector')) { $parent = array_keys(taxonomy_term_load_parents($term->id())); $children = taxonomy_get_tree($vocabulary->id(), $term->id()); diff --git a/core/modules/update/lib/Drupal/update/UpdateSettingsForm.php b/core/modules/update/lib/Drupal/update/UpdateSettingsForm.php index d2d4186..7fd77d2 100644 --- a/core/modules/update/lib/Drupal/update/UpdateSettingsForm.php +++ b/core/modules/update/lib/Drupal/update/UpdateSettingsForm.php @@ -25,7 +25,7 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('update.settings'); + $config = $this->config('update.settings'); $form['update_check_frequency'] = array( '#type' => 'radios', @@ -104,7 +104,7 @@ public function validateForm(array &$form, array &$form_state) { * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { - $config = $this->configFactory->get('update.settings'); + $config = $this->config('update.settings'); // See if the update_check_disabled setting is being changed, and if so, // invalidate all update status data. if ($form_state['values']['update_check_disabled'] != $config->get('check.disabled_extensions')) { diff --git a/core/modules/user/lib/Drupal/user/AccountSettingsForm.php b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php index 66ffaf1..e29bc26 100644 --- a/core/modules/user/lib/Drupal/user/AccountSettingsForm.php +++ b/core/modules/user/lib/Drupal/user/AccountSettingsForm.php @@ -59,9 +59,9 @@ public function getFormId() { * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { - $config = $this->configFactory->get('user.settings'); - $mail_config = $this->configFactory->get('user.mail'); - $site_config = $this->configFactory->get('system.site'); + $config = $this->config('user.settings'); + $mail_config = $this->config('user.mail'); + $site_config = $this->config('system.site'); // Settings for anonymous users. $form['anonymous_settings'] = array( @@ -410,7 +410,7 @@ public function buildForm(array $form, array &$form_state) { public function submitForm(array &$form, array &$form_state) { parent::submitForm($form, $form_state); - $this->configFactory->get('user.settings') + $this->config('user.settings') ->set('anonymous', $form_state['values']['anonymous']) ->set('admin_role', $form_state['values']['user_admin_role']) ->set('register', $form_state['values']['user_register']) @@ -422,7 +422,7 @@ public function submitForm(array &$form, array &$form_state) { ->set('notify.status_blocked', $form_state['values']['user_mail_status_blocked_notify']) ->set('notify.status_canceled', $form_state['values']['user_mail_status_canceled_notify']) ->save(); - $this->configFactory->get('user.mail') + $this->config('user.mail') ->set('cancel_confirm.body', $form_state['values']['user_mail_cancel_confirm_body']) ->set('cancel_confirm.subject', $form_state['values']['user_mail_cancel_confirm_subject']) ->set('password_reset.body', $form_state['values']['user_mail_password_reset_body']) @@ -440,7 +440,7 @@ public function submitForm(array &$form, array &$form_state) { ->set('status_canceled.body', $form_state['values']['user_mail_status_canceled_body']) ->set('status_canceled.subject', $form_state['values']['user_mail_status_canceled_subject']) ->save(); - $this->configFactory->get('system.site') + $this->config('system.site') ->set('mail_notification', $form_state['values']['mail_notification_address']) ->save(); } diff --git a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php index 9f76e1e..c453c76 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php @@ -7,10 +7,7 @@ namespace Drupal\user\Form; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\ContentEntityConfirmFormBase; -use Drupal\Core\Entity\EntityManagerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a confirmation form for cancelling user account. @@ -25,13 +22,6 @@ class UserCancelForm extends ContentEntityConfirmFormBase { protected $cancelMethods; /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * The user being cancelled. * * @var \Drupal\user\UserInterface @@ -39,29 +29,6 @@ class UserCancelForm extends ContentEntityConfirmFormBase { protected $entity; /** - * Constructs an EntityForm object. - * - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. - */ - public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory) { - parent::__construct($entity_manager); - $this->configFactory = $config_factory; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager'), - $container->get('config.factory') - ); - } - - /** * {@inheritdoc} */ public function getQuestion() { @@ -82,7 +49,7 @@ public function getCancelRoute() { */ public function getDescription() { $description = ''; - $default_method = $this->configFactory->get('user.settings')->get('cancel_method'); + $default_method = $this->config('user.settings')->get('cancel_method'); if ($this->currentUser()->hasPermission('administer users') || $this->currentUser()->hasPermission('select account cancellation method')) { $description = $this->t('Select the method to cancel the account above.'); } @@ -129,7 +96,7 @@ public function buildForm(array $form, array &$form_state) { '#description' => $this->t('When enabled, the user must confirm the account cancellation via e-mail.'), ); // Also allow to send account canceled notification mail, if enabled. - $default_notify = $this->configFactory->get('user.settings')->get('notify.status_canceled'); + $default_notify = $this->config('user.settings')->get('notify.status_canceled'); $form['user_cancel_notify'] = array( '#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled.'), diff --git a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php index 8e99476..b0dd621 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php @@ -8,7 +8,6 @@ namespace Drupal\user\Form; use Drupal\Component\Utility\String; -use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\ConfirmFormBase; use Drupal\Core\Routing\UrlGeneratorInterface; @@ -30,13 +29,6 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { protected $tempStoreFactory; /** - * The config factory. - * - * @var \Drupal\Core\Config\ConfigFactoryInterface - */ - protected $configFactory; - - /** * The user storage. * * @var \Drupal\user\UserStorageInterface @@ -55,16 +47,13 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { * * @param \Drupal\user\TempStoreFactory $temp_store_factory * The temp store factory. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The config factory. * @param \Drupal\user\UserStorageInterface $user_storage * The user storage. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ - public function __construct(TempStoreFactory $temp_store_factory, ConfigFactoryInterface $config_factory, UserStorageInterface $user_storage, EntityManagerInterface $entity_manager) { + public function __construct(TempStoreFactory $temp_store_factory, UserStorageInterface $user_storage, EntityManagerInterface $entity_manager) { $this->tempStoreFactory = $temp_store_factory; - $this->configFactory = $config_factory; $this->userStorage = $user_storage; $this->entityManager = $entity_manager; } @@ -75,7 +64,6 @@ public function __construct(TempStoreFactory $temp_store_factory, ConfigFactoryI public static function create(ContainerInterface $container) { return new static( $container->get('user.tempstore'), - $container->get('config.factory'), $container->get('entity.manager')->getStorage('user'), $container->get('entity.manager') ); @@ -166,7 +154,7 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled.'), '#default_value' => FALSE, - '#access' => $this->configFactory->get('user.settings')->get('notify.status_canceled'), + '#access' => $this->config('user.settings')->get('notify.status_canceled'), '#description' => $this->t('When enabled, the user will receive an e-mail notification after the account has been canceled.'), ); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php index 3ef9653..90dc49d 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/AdvancedSettingsForm.php @@ -28,7 +28,7 @@ public function getFormId() { public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); - $config = $this->configFactory->get('views.settings'); + $config = $this->config('views.settings'); $form['cache'] = array( '#type' => 'details', '#title' => $this->t('Caching'), @@ -91,7 +91,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('views.settings') + $this->config('views.settings') ->set('skip_cache', $form_state['values']['skip_cache']) ->set('sql_signature', $form_state['values']['sql_signature']) ->set('no_javascript', $form_state['values']['no_javascript']) diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/BasicSettingsForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BasicSettingsForm.php index caade6e..a441805 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/BasicSettingsForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/BasicSettingsForm.php @@ -27,7 +27,7 @@ public function getFormId() { public function buildForm(array $form, array &$form_state) { $form = parent::buildForm($form, $form_state); - $config = $this->configFactory->get('views.settings'); + $config = $this->config('views.settings'); $options = array(); foreach (list_themes() as $name => $theme) { if ($theme->status) { @@ -127,7 +127,7 @@ public function buildForm(array $form, array &$form_state) { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $this->configFactory->get('views.settings') + $this->config('views.settings') ->set('ui.show.master_display', $form_state['values']['ui_show_master_display']) ->set('ui.show.advanced_column', $form_state['values']['ui_show_advanced_column']) ->set('ui.show.display_embed', $form_state['values']['ui_show_display_embed'])