diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 851c259..8e24668 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1714,9 +1714,6 @@ function _drupal_bootstrap_configuration() { // Detect string handling method. Unicode::check(); - // Load the procedural configuration system helper functions. - require_once __DIR__ . '/config.inc'; - // Set the Drupal custom error handler. (requires \Drupal::config()) set_error_handler('_drupal_error_handler'); set_exception_handler('_drupal_exception_handler'); diff --git a/core/includes/config.inc b/core/includes/config.inc deleted file mode 100644 index c673744..0000000 --- a/core/includes/config.inc +++ /dev/null @@ -1,56 +0,0 @@ -listAll() instead. - */ -function config_get_storage_names_with_prefix($prefix = '') { - return \Drupal::configFactory()->listAll($prefix); -} - -/** - * Retrieves a configuration object. - * - * This is the main entry point to the configuration API. Calling - * @code \Drupal::config('book.admin') @endcode will return a configuration - * object in which the book module can store its administrative settings. - * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. - * Use \Drupal::config(). - * - * @param string $name - * The name of the configuration object to retrieve. The name corresponds to - * a configuration file. For @code \Drupal::config('book.admin') @endcode, - * the config object returned will contain the contents of book.admin - * configuration file. - * - * @return \Drupal\Core\Config\Config - * A configuration object. - */ -function config($name) { - return \Drupal::config($name); -} - -/** - * Returns the typed config manager service. - * - * Use the typed data manager service for creating typed configuration objects. - * - * @deprecated Deprecated since Drupal 8.x-dev, to be removed in Drupal 8.0. - * Use \Drupal::service('config.typed') instead. - * - * @see \Drupal\Core\TypedData\TypedDataManager::create() - * - * @return \Drupal\Core\Config\TypedConfigManager - */ -function config_typed() { - return \Drupal::service('config.typed'); -} - diff --git a/core/includes/update.inc b/core/includes/update.inc index 5700d38..fc1e0af 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -825,7 +825,7 @@ function update_language_list($flags = Language::STATE_CONFIGURABLE) { if (\Drupal::languageManager()->isMultilingual() || \Drupal::moduleHandler()->moduleExists('language')) { // Use language module configuration if available. We can not use // entity_load_multiple() because this breaks during updates. - $language_entities = config_get_storage_names_with_prefix('language.entity.'); + $language_entities = \Drupal::configFactory()->listAll('language.entity.'); // Initialize default property so callers have an easy reference and can // save the same object without data loss. diff --git a/core/lib/Drupal/Core/Config/Schema/Element.php b/core/lib/Drupal/Core/Config/Schema/Element.php index d4e29db..2563ec5 100644 --- a/core/lib/Drupal/Core/Config/Schema/Element.php +++ b/core/lib/Drupal/Core/Config/Schema/Element.php @@ -25,7 +25,7 @@ * Create typed config object. */ protected function parseElement($key, $data, $definition) { - return config_typed()->create($definition, $data, $key, $this); + return \Drupal::service('config.typed')->create($definition, $data, $key, $this); } } diff --git a/core/modules/block/custom_block/custom_block.module b/core/modules/block/custom_block/custom_block.module index 633e9fb..fd50c03 100644 --- a/core/modules/block/custom_block/custom_block.module +++ b/core/modules/block/custom_block/custom_block.module @@ -112,7 +112,7 @@ function custom_block_entity_type_alter(array &$entity_types) { */ function custom_block_entity_bundle_info() { $bundles = array(); - foreach (config_get_storage_names_with_prefix('custom_block.type.') as $config_name) { + foreach (\Drupal::configFactory()->listAll('custom_block.type.') as $config_name) { $config = \Drupal::config($config_name); $bundles['custom_block'][$config->get('id')]['label'] = $config->get('label'); } diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index 6c606ec..754d968 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -79,7 +79,7 @@ function breakpoint_modules_uninstalled($modules) { * Either Breakpoint::SOURCE_TYPE_THEME or Breakpoint::SOURCE_TYPE_MODULE. */ function _breakpoint_delete_breakpoints($list, $source_type) { - $ids = config_get_storage_names_with_prefix('breakpoint.breakpoint_group.' . $source_type . '.'); + $ids = \Drupal::configFactory()->listAll('breakpoint.breakpoint_group.' . $source_type . '.'); $entity_manager = \Drupal::entityManager(); $entity_type = $entity_manager->getDefinition('breakpoint_group'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php index ad21904..e9d7562 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -41,21 +41,21 @@ public function setUp() { */ function testSchemaMapping() { // Nonexistent configuration key will have Unknown as metadata. - $this->assertIdentical(FALSE, config_typed()->hasConfigSchema('config_test.no_such_key')); - $definition = config_typed()->getDefinition('config_test.no_such_key'); + $this->assertIdentical(FALSE, \Drupal::service('config.typed')->hasConfigSchema('config_test.no_such_key')); + $definition = \Drupal::service('config.typed')->getDefinition('config_test.no_such_key'); $expected = array(); $expected['label'] = 'Unknown'; $expected['class'] = '\Drupal\Core\Config\Schema\Property'; $this->assertEqual($definition, $expected, 'Retrieved the right metadata for nonexistent configuration.'); // Configuration file without schema will return Unknown as well. - $this->assertIdentical(FALSE, config_typed()->hasConfigSchema('config_test.noschema')); - $definition = config_typed()->getDefinition('config_test.noschema'); + $this->assertIdentical(FALSE, \Drupal::service('config.typed')->hasConfigSchema('config_test.noschema')); + $definition = \Drupal::service('config.typed')->getDefinition('config_test.noschema'); $this->assertEqual($definition, $expected, 'Retrieved the right metadata for configuration with no schema.'); // Configuration file with only some schema. - $this->assertIdentical(TRUE, config_typed()->hasConfigSchema('config_test.someschema')); - $definition = config_typed()->getDefinition('config_test.someschema'); + $this->assertIdentical(TRUE, \Drupal::service('config.typed')->hasConfigSchema('config_test.someschema')); + $definition = \Drupal::service('config.typed')->getDefinition('config_test.someschema'); $expected = array(); $expected['label'] = 'Schema test data'; $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; @@ -64,7 +64,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for configuration with only some schema.'); // Check type detection on elements with undefined types. - $config = config_typed()->get('config_test.someschema'); + $config = \Drupal::service('config.typed')->get('config_test.someschema'); $definition = $config['testitem']->getDataDefinition(); $expected = array(); $expected['label'] = 'Test item'; @@ -79,7 +79,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Automatic type fallback on non-string item worked.'); // Simple case, straight metadata. - $definition = config_typed()->getDefinition('system.maintenance'); + $definition = \Drupal::service('config.typed')->getDefinition('system.maintenance'); $expected = array(); $expected['label'] = 'Maintenance mode'; $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; @@ -94,7 +94,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for system.maintenance'); // More complex case, generic type. Metadata for image style. - $definition = config_typed()->getDefinition('image.style.large'); + $definition = \Drupal::service('config.typed')->getDefinition('image.style.large'); $expected = array(); $expected['label'] = 'Image style'; $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; @@ -116,7 +116,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for image.style.large'); // More complex, type based on a complex one. - $definition = config_typed()->getDefinition('image.effect.image_scale'); + $definition = \Drupal::service('config.typed')->getDefinition('image.effect.image_scale'); // This should be the schema for image.effect.image_scale. $expected = array(); $expected['label'] = 'Image scale'; @@ -131,7 +131,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for image.effect.image_scale'); // Most complex case, get metadata for actual configuration element. - $effects = config_typed()->get('image.style.medium')->get('effects'); + $effects = \Drupal::service('config.typed')->get('image.style.medium')->get('effects'); $definition = $effects['bddf0d06-42f9-4c75-a700-a33cafa25ea0']['data']->getDataDefinition(); // This should be the schema for image.effect.image_scale, reuse previous one. $expected['type'] = 'image.effect.image_scale'; @@ -139,7 +139,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for the first effect of image.style.medium'); // More complex, multiple filesystem marker test. - $definition = config_typed()->getDefinition('config_test.someschema.somemodule.section_one.subsection'); + $definition = \Drupal::service('config.typed')->getDefinition('config_test.someschema.somemodule.section_one.subsection'); // This should be the schema of config_test.someschema.somemodule.*.*. $expected = array(); $expected['label'] = 'Schema multiple filesytem marker test'; @@ -151,7 +151,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for config_test.someschema.somemodule.section_one.subsection'); - $definition = config_typed()->getDefinition('config_test.someschema.somemodule.section_two.subsection'); + $definition = \Drupal::service('config.typed')->getDefinition('config_test.someschema.somemodule.section_two.subsection'); // The other file should have the same schema. $this->assertEqual($definition, $expected, 'Retrieved the right metadata for config_test.someschema.somemodule.section_two.subsection'); } @@ -160,7 +160,7 @@ function testSchemaMapping() { * Tests metadata retrieval with several levels of %parent indirection. */ function testSchemaMappingWithParents() { - $config_data = config_typed()->get('config_test.someschema.with_parents'); + $config_data = \Drupal::service('config.typed')->get('config_test.someschema.with_parents'); // Test fetching parent one level up. $entry = $config_data->get('one_level'); @@ -198,7 +198,7 @@ function testSchemaMappingWithParents() { */ function testSchemaData() { // Try some simple properties. - $meta = config_typed()->get('system.site'); + $meta = \Drupal::service('config.typed')->get('system.site'); $property = $meta->get('name'); $this->assertTrue($property instanceof StringInterface, 'Got the right wrapper fo the site name property.'); $this->assertEqual($property->getValue(), 'Drupal', 'Got the right string value for site name data.'); @@ -224,7 +224,7 @@ function testSchemaData() { $this->assertTrue(count($values) == 3 && $values['front'] == 'user', 'Got the right property values for site page.'); // Now let's try something more complex, with nested objects. - $wrapper = config_typed()->get('image.style.large'); + $wrapper = \Drupal::service('config.typed')->get('image.style.large'); $effects = $wrapper->get('effects'); // The function is_array() doesn't work with ArrayAccess, so we use count(). @@ -237,7 +237,7 @@ function testSchemaData() { // Finally update some object using a configuration wrapper. $new_slogan = 'Site slogan for testing configuration metadata'; - $wrapper = config_typed()->get('system.site'); + $wrapper = \Drupal::service('config.typed')->get('system.site'); $wrapper->set('slogan', $new_slogan); $site_slogan = $wrapper->get('slogan'); $this->assertEqual($site_slogan->getValue(), $new_slogan, 'Successfully updated the contained configuration data'); diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index fe90799..f00123c 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -84,7 +84,7 @@ function contact_entity_type_alter(array &$entity_types) { */ function contact_entity_bundle_info() { $bundles = array(); - foreach (config_get_storage_names_with_prefix('contact.category.') as $config_name) { + foreach (\Drupal::configFactory()->listAll('contact.category.') as $config_name) { $config = \Drupal::config($config_name); $bundles['contact_message'][$config->get('id')]['label'] = $config->get('label'); } diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index 8c65f1e..41657dc 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -146,7 +146,7 @@ function content_translation_entity_bundle_info_alter(&$bundles) { * Implements hook_entity_field_info_alter(). */ function content_translation_entity_field_info_alter(&$info, $entity_type) { - $translation_settings = config('content_translation.settings')->get($entity_type); + $translation_settings = \Drupal::config('content_translation.settings')->get($entity_type); if ($translation_settings) { // Currently field translatability is defined per-field but we may want to diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index f921fcf..de5b1b9 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -81,7 +81,7 @@ function entity_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_new) // Rename entity displays. $entity_type = \Drupal::entityManager()->getDefinition('entity_view_display'); if ($bundle_old !== $bundle_new) { - $ids = config_get_storage_names_with_prefix('entity.view_display.' . $entity_type_id . '.' . $bundle_old . '.'); + $ids = \Drupal::configFactory()->listAll('entity.view_display.' . $entity_type_id . '.' . $bundle_old . '.'); foreach ($ids as $id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_type->getConfigPrefix()); $display = entity_load('entity_view_display', $id); @@ -95,7 +95,7 @@ function entity_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_new) // Rename entity form displays. $entity_type = \Drupal::entityManager()->getDefinition('entity_form_display'); if ($bundle_old !== $bundle_new) { - $ids = config_get_storage_names_with_prefix('entity.form_display.' . $entity_type_id . '.' . $bundle_old . '.'); + $ids = \Drupal::configFactory()->listAll('entity.form_display.' . $entity_type_id . '.' . $bundle_old . '.'); foreach ($ids as $id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_type->getConfigPrefix()); $form_display = entity_load('entity_form_display', $id); @@ -113,7 +113,7 @@ function entity_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_new) function entity_entity_bundle_delete($entity_type_id, $bundle) { // Remove entity displays of the deleted bundle. $entity_type = \Drupal::entityManager()->getDefinition('entity_view_display'); - $ids = config_get_storage_names_with_prefix('entity.view_display.' . $entity_type_id . '.' . $bundle . '.'); + $ids = \Drupal::configFactory()->listAll('entity.view_display.' . $entity_type_id . '.' . $bundle . '.'); foreach ($ids as &$id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_type->getConfigPrefix()); } @@ -121,7 +121,7 @@ function entity_entity_bundle_delete($entity_type_id, $bundle) { // Remove entity form displays of the deleted bundle. $entity_type = \Drupal::entityManager()->getDefinition('entity_form_display'); - $ids = config_get_storage_names_with_prefix('entity.form_display.' . $entity_type_id . '.' . $bundle . '.'); + $ids = \Drupal::configFactory()->listAll('entity.form_display.' . $entity_type_id . '.' . $bundle . '.'); foreach ($ids as &$id) { $id = ConfigStorageController::getIDFromConfigName($id, $entity_type->getConfigPrefix()); } diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 72d4af5..969b719 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -59,7 +59,7 @@ class FieldInfo { * * @var \Drupal\Core\Config\ConfigFactoryInterface */ - protected $config; + protected $configFactory; /** * The language manager. @@ -136,7 +136,7 @@ class FieldInfo { * * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * The cache backend to use. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config + * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory object to use. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler class to use for invoking hooks. @@ -145,10 +145,10 @@ class FieldInfo { * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager to use. */ - public function __construct(CacheBackendInterface $cache_backend, ConfigFactoryInterface $config, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager, LanguageManagerInterface $language_manager) { + public function __construct(CacheBackendInterface $cache_backend, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager, LanguageManagerInterface $language_manager) { $this->cacheBackend = $cache_backend; $this->moduleHandler = $module_handler; - $this->config = $config; + $this->configFactory = $config_factory; $this->fieldTypeManager = $field_type_manager; $this->languageManager = $language_manager; } @@ -201,13 +201,13 @@ public function getFieldMap() { $map = array(); // Get fields. - foreach (config_get_storage_names_with_prefix('field.field.') as $config_id) { - $field_config = $this->config->get($config_id)->get(); + foreach ($this->configFactory->listAll('field.field.') as $config_id) { + $field_config = $this->configFactory->get($config_id)->get(); $fields[$field_config['uuid']] = $field_config; } // Get field instances. - foreach (config_get_storage_names_with_prefix('field.instance.') as $config_id) { - $instance_config = $this->config->get($config_id)->get(); + foreach ($this->configFactory->listAll('field.instance.') as $config_id) { + $instance_config = $this->configFactory->get($config_id)->get(); $field_uuid = $instance_config['field_uuid']; if (isset($fields[$field_uuid])) { $field = $fields[$field_uuid]; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php index a4aea5b..2e7606e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverview.php @@ -8,6 +8,7 @@ namespace Drupal\field_ui; use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\EntityManagerInterface; @@ -43,9 +44,11 @@ class DisplayOverview extends DisplayOverviewBase { * The widget or formatter plugin manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler class to use for invoking hooks. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The configuration factory. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_manager, $field_type_manager, $plugin_manager); + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { + parent::__construct($entity_manager, $field_type_manager, $plugin_manager, $config_factory); $this->moduleHandler = $module_handler; } @@ -57,8 +60,9 @@ public static function create(ContainerInterface $container) { $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), $container->get('plugin.manager.field.formatter'), - $container->get('module_handler') - ); + $container->get('module_handler'), + $container->get('config.factory') + ); } /** diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index 5de03d9..ce2eb1d 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -8,6 +8,7 @@ namespace Drupal\field_ui; use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -41,6 +42,13 @@ protected $fieldTypes; /** + * The config factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** * Constructs a new DisplayOverviewBase. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager @@ -49,12 +57,15 @@ * The field type manager. * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager * The widget or formatter plugin manager. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The configuration factory. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager) { + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager, ConfigFactoryInterface $config_factory) { parent::__construct($entity_manager); $this->fieldTypes = $field_type_manager->getConfigurableDefinitions(); $this->pluginManager = $plugin_manager; + $this->configFactory = $config_factory; } /** @@ -64,7 +75,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), - $container->get('plugin.manager.field.widget') + $container->get('plugin.manager.field.widget'), + $container->get('config.factory') ); } @@ -772,7 +784,7 @@ protected function getDisplays() { $display_entity_type = $this->getDisplayType(); $entity_type = $this->entityManager->getDefinition($display_entity_type); $config_prefix = $entity_type->getConfigPrefix(); - $ids = config_get_storage_names_with_prefix($config_prefix . '.' . $this->entity_type . '.' . $this->bundle . '.'); + $ids = $this->configFactory->listAll($config_prefix . '.' . $this->entity_type . '.' . $this->bundle . '.'); foreach ($ids as $id) { $config_id = str_replace($config_prefix . '.', '', $id); list(,, $display_mode) = explode('.', $config_id); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php index 1b7fc9e..cfebf42 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FormDisplayOverview.php @@ -8,6 +8,7 @@ namespace Drupal\field_ui; use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -43,9 +44,11 @@ class FormDisplayOverview extends DisplayOverviewBase { * The widget or formatter plugin manager. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to use for invoking hooks. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The configuration factory. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_manager, $field_type_manager, $plugin_manager); + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { + parent::__construct($entity_manager, $field_type_manager, $plugin_manager, $config_factory); $this->moduleHandler = $module_handler; } @@ -57,7 +60,8 @@ public static function create(ContainerInterface $container) { $container->get('entity.manager'), $container->get('plugin.manager.field.field_type'), $container->get('plugin.manager.field.widget'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('config.factory') ); } diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index df50185..8eb1d34 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -100,7 +100,7 @@ function menu_entity_type_build(array &$entity_types) { */ function menu_entity_bundle_info() { $bundles = array(); - $config_names = config_get_storage_names_with_prefix('system.menu.'); + $config_names = \Drupal::configFactory()->listAll('system.menu.'); foreach ($config_names as $config_name) { $config = \Drupal::config($config_name); $bundles['menu_link'][$config->get('id')] = array( diff --git a/core/modules/node/node.install b/core/modules/node/node.install index eaa022c..a6af612 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -456,7 +456,7 @@ function node_install() { */ function node_uninstall() { // Delete node type variables. - $types = config_get_storage_names_with_prefix('node.type.'); + $types = \Drupal::configFactory()->listAll('node.type.'); foreach ($types as $config_name) { $type = \Drupal::config($config_name)->get('type'); \Drupal::config('language.settings')->clear('node. ' . $type . '.language.default_configuration')->save(); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index b66ba18..74dc548 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -343,7 +343,7 @@ function node_type_get_names() { // Not using node_type_get_types() or entity_load_multiple() here, to allow // this function being used in hook_entity_type_build() implementations. // @todo Consider to convert this into a generic config entity helper. - $config_names = config_get_storage_names_with_prefix('node.type.'); + $config_names = \Drupal::configFactory()->listAll('node.type.'); $names = array(); foreach ($config_names as $config_name) { $config = \Drupal::config($config_name); @@ -1778,9 +1778,9 @@ function node_modules_installed($modules) { */ function node_modules_uninstalled($modules) { // Remove module-specific settings from all node types. - $config_names = config_get_storage_names_with_prefix('node.type.'); + $config_names = \Drupal::configFactory()->listAll('node.type.'); foreach ($config_names as $config_name) { - $config = config($config_name); + $config = \Drupal::config($config_name); $changed = FALSE; foreach ($modules as $module) { if ($config->get('settings.' . $module)) { diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php index c6ca292..26f793d 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CrudTest.php @@ -44,7 +44,7 @@ function testMappingCreation() { // Save bundle mapping config. rdf_get_mapping($this->entity_type, $this->bundle)->save(); // Test that config file was saved. - $mapping_config = config_get_storage_names_with_prefix('rdf.mapping.'); + $mapping_config = \Drupal::configFactory()->listAll('rdf.mapping.'); $this->assertTrue(in_array($mapping_config_name, $mapping_config), 'Rdf mapping config saved.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php index 582ad5b..c668fe9 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/InstallTest.php @@ -58,7 +58,7 @@ public function testDrupalWriteRecord() { */ public function testEnableUserTwice() { \Drupal::moduleHandler()->install(array('user'), FALSE); - $this->assertIdentical(config('system.module')->get('enabled.user'), 0); + $this->assertIdentical(\Drupal::config('system.module')->get('enabled.user'), 0); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php index 95844f6..b644c19 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleTestBase.php @@ -137,7 +137,7 @@ function assertModuleConfig($module) { * TRUE if no configuration was found, FALSE otherwise. */ function assertNoModuleConfig($module) { - $names = config_get_storage_names_with_prefix($module . '.'); + $names = \Drupal::configFactory()->listAll($module . '.'); return $this->assertFalse($names, format_string('No configuration found for @module module.', array('@module' => $module))); } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php index e4e7b7b..623d995 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceUnitTest.php @@ -65,7 +65,7 @@ public function testClear() { $source .= '[bogus:token]'; // Replace with with the clear parameter, only the valid token should remain. - $target = String::checkPlain(config('system.site')->get('name')); + $target = String::checkPlain(\Drupal::config('system.site')->get('name')); $result = $this->tokenService->replace($source, array(), array('langcode' => $this->languageInterface->id, 'clear' => TRUE)); $this->assertEqual($target, $result, 'Valid tokens replaced while invalid tokens ignored.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php index 8f6e9b6..390687d 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeSuggestionsAlterTest.php @@ -43,7 +43,7 @@ function testTemplateSuggestions() { // Enable test_theme, it contains a template suggested by theme_test.module // in theme_test_theme_suggestions_theme_test_suggestion_provided(). - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); @@ -59,7 +59,7 @@ function testGeneralSuggestionsAlter() { $this->assertText('Original template for testing hook_theme_suggestions_alter().'); // Enable test_theme and test that themes can alter template suggestions. - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/general-suggestion-alter'); @@ -80,7 +80,7 @@ function testTemplateSuggestionsAlter() { $this->assertText('Original template for testing hook_theme_suggestions_HOOK_alter().'); // Enable test_theme and test that themes can alter template suggestions. - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/suggestion-alter'); @@ -101,7 +101,7 @@ function testSpecificSuggestionsAlter() { $this->drupalGet('theme-test/specific-suggestion-alter'); $this->assertText('Template for testing specific theme calls.'); - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); @@ -125,7 +125,7 @@ function testThemeFunctionSuggestionsAlter() { $this->assertText('Original theme function.'); // Enable test_theme and test that themes can alter theme suggestions. - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/function-suggestion-alter'); @@ -146,7 +146,7 @@ function testThemeFunctionSuggestionsAlter() { */ function testExecutionOrder() { // Enable our test theme and module. - config('system.theme') + \Drupal::config('system.theme') ->set('default', 'test_theme') ->save(); \Drupal::moduleHandler()->install(array('theme_suggestions_test')); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index e51eef8..d9147c0 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -435,7 +435,7 @@ function taxonomy_vocabulary_get_names() { if (!isset($names)) { $names = array(); - $config_names = config_get_storage_names_with_prefix('taxonomy.vocabulary.'); + $config_names = \Drupal::configFactory()->listAll('taxonomy.vocabulary.'); foreach ($config_names as $config_name) { $id = substr($config_name, strlen('taxonomy.vocabulary.')); $names[$id] = $id;