diff --git a/core/core.services.yml b/core/core.services.yml index b850c9e..b1091dd 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -70,6 +70,9 @@ services: class: Drupal\Core\Config\FileStorage factory_class: Drupal\Core\Config\FileStorageFactory factory_method: getActive + config.manager: + class: Drupal\Core\Config\ConfigManager + arguments: ['@entity.manager', '@config.factory', '@config.typed', '@string_translation'] config.storage: class: Drupal\Core\Config\CachedStorage arguments: ['@config.cachedstorage.storage', '@cache.config'] @@ -83,7 +86,7 @@ services: arguments: ['@config.storage', '@event_dispatcher', '@config.typed'] config.installer: class: Drupal\Core\Config\ConfigInstaller - arguments: ['@config.factory', '@config.storage', '@config.typed', '@entity.manager', '@event_dispatcher'] + arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher'] config.storage.staging: class: Drupal\Core\Config\FileStorage factory_class: Drupal\Core\Config\FileStorageFactory @@ -539,7 +542,7 @@ services: class: Drupal\Core\EventSubscriber\ConfigSnapshotSubscriber tags: - { name: event_subscriber } - arguments: ['@config.storage', '@config.storage.snapshot'] + arguments: ['@config.manager', '@config.storage', '@config.storage.snapshot'] exception_controller: class: Drupal\Core\Controller\ExceptionController arguments: ['@content_negotiation', '@string_translation', '@title_resolver', '@html_page_renderer', '@html_fragment_renderer'] diff --git a/core/includes/config.inc b/core/includes/config.inc index 8c3ded3..b406f00 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -1,50 +1,17 @@ listAll($name . '.'); - foreach ($config_names as $config_name) { - \Drupal::config($config_name)->delete(); - } - $schema_dir = drupal_get_path($type, $name) . '/config/schema'; - if (is_dir($schema_dir)) { - // Refresh the schema cache if uninstalling an extension that provides - // configuration schema. - \Drupal::service('config.typed')->clearCachedDefinitions(); - } -} - -/** * Gets configuration object names starting with a given prefix. * - * @see \Drupal\Core\Config\StorageInterface::listAll() + * @deprecated as of Drupal 8.0. Use \Drupal::configFactory()->listAll() instead. */ function config_get_storage_names_with_prefix($prefix = '') { - return \Drupal::service('config.storage')->listAll($prefix); + return \Drupal::configFactory()->listAll($prefix); } /** @@ -70,26 +37,12 @@ function config($name) { } /** - * Returns the entity type of a configuration object. - * - * @param string $name - * The configuration object name. - * - * @return string|null - * Either the entity type name, or NULL if none match. - */ -function config_get_entity_type_by_name($name) { - $entities = array_filter(\Drupal::entityManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($name) { - return ($config_prefix = $entity_type->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0; - }); - return key($entities); -} - -/** * Returns the typed config manager service. * * Use the typed data manager service for creating typed configuration objects. * + * @deprecated as of Drupal 8.0. Use \Drupal::service('config.typed') instead. + * * @see \Drupal\Core\TypedData\TypedDataManager::create() * * @return \Drupal\Core\Config\TypedConfigManager @@ -98,57 +51,3 @@ function config_typed() { return \Drupal::service('config.typed'); } -/** - * Creates a configuration snapshot following a successful import. - * - * @param \Drupal\Core\Config\StorageInterface $source_storage - * The storage to synchronize configuration from. - * @param \Drupal\Core\Config\StorageInterface $snapshot_storage - * The storage to synchronize configuration to. - */ -function config_import_create_snapshot(StorageInterface $source_storage, StorageInterface $snapshot_storage) { - $snapshot_storage->deleteAll(); - foreach ($source_storage->listAll() as $name) { - $snapshot_storage->write($name, $source_storage->read($name)); - } -} - -/** - * Return a formatted diff of a named config between two storages. - * - * @param \Drupal\Core\Config\StorageInterface $source_storage - * The storage to diff configuration from. - * @param \Drupal\Core\Config\StorageInterface $target_storage - * The storage to diff configuration to. - * @param string $name - * The name of the configuration object to diff. - * - * @return core/lib/Drupal/Component/Diff - * A formatted string showing the difference between the two storages. - * - * @todo Make renderer injectable - */ -function config_diff(StorageInterface $source_storage, StorageInterface $target_storage, $name) { - require_once DRUPAL_ROOT . '/core/lib/Drupal/Component/Diff/DiffEngine.php'; - - // The output should show configuration object differences formatted as YAML. - // But the configuration is not necessarily stored in files. Therefore, they - // need to be read and parsed, and lastly, dumped into YAML strings. - $dumper = new Dumper(); - $dumper->setIndentation(2); - - $source_data = explode("\n", $dumper->dump($source_storage->read($name), PHP_INT_MAX)); - $target_data = explode("\n", $dumper->dump($target_storage->read($name), PHP_INT_MAX)); - - // Check for new or removed files. - if ($source_data === array('false')) { - // Added file. - $source_data = array(t('File added')); - } - if ($target_data === array('false')) { - // Deleted file. - $target_data = array(t('File removed')); - } - - return new Diff($source_data, $target_data); -} diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 0b25e59..80e586c 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -2191,7 +2191,7 @@ function install_finished(&$install_state) { // Save a snapshot of the initially installed configuration. $active = \Drupal::service('config.storage'); $snapshot = \Drupal::service('config.storage.snapshot'); - config_import_create_snapshot($active, $snapshot); + \Drupal::service('config.manager')->createSnapshot($active, $snapshot); return $output; } diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 7029d11..8b74a70 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -346,6 +346,13 @@ public function getLanguageConfigName($langcode, $name) { } /** + * {@inheritdoc} + */ + public function listAll($prefix = '') { + return $this->storage->listAll($prefix); + } + + /** * Determines if a particular configuration object can be overridden. * * Language override configuration should not be overridden. diff --git a/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php b/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php index c01d472..6634047 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigFactoryInterface.php @@ -182,4 +182,18 @@ public function getLanguageConfigNames(array $names); */ public function getLanguageConfigName($langcode, $name); + /** + * Gets configuration object names starting with a given prefix. + * + * @see \Drupal\Core\Config\StorageInterface::listAll() + * + * @param string $prefix + * (optional) The prefix to search for. If omitted, all configuration object + * names that exist are returned. + * + * @return array + * An array containing matching configuration object names. + */ + public function listAll($prefix = ''); + } diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index e2354f4..92476b5 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -7,10 +7,7 @@ namespace Drupal\Core\Config; -use Drupal\Core\Config\TypedConfigManager; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Lock\LockBackendInterface; -use Drupal\Component\Uuid\UuidInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -54,25 +51,25 @@ class ConfigImporter { protected $eventDispatcher; /** - * The configuration factory. + * The configuration manager. * - * @var \Drupal\Core\Config\ConfigFactory + * @var \Drupal\Core\Config\ConfigManagerInterface */ - protected $configFactory; + protected $configManager; /** - * The plugin manager for entities. + * The used lock backend instance. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Lock\LockBackendInterface */ - protected $entityManager; + protected $lock; /** - * The used lock backend instance. + * The typed config manager. * - * @var \Drupal\Core\Lock\LockBackendInterface + * @var \Drupal\Core\Config\TypedConfigManager */ - protected $lock; + protected $typedConfigManager; /** * List of changes processed by the import(). @@ -89,20 +86,6 @@ class ConfigImporter { protected $validated; /** - * The UUID service. - * - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuidService; - - /** - * The typed config manager. - * - * @var \Drupal\Core\Config\TypedConfigManager - */ - protected $typedConfigManager; - - /** * Constructs a configuration import object. * * @param \Drupal\Core\Config\StorageComparerInterface $storage_comparer @@ -110,24 +93,18 @@ class ConfigImporter { * access the source and target storage objects. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher used to notify subscribers of config import events. - * @param \Drupal\Core\Config\ConfigFactory $config_factory - * The config factory that statically caches config objects. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager used to import config entities. + * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager + * The configuration manager. * @param \Drupal\Core\Lock\LockBackendInterface * The lock backend to ensure multiple imports do not occur at the same time. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service - * The UUID service. * @param \Drupal\Core\Config\TypedConfigManager $typed_config * The typed configuration manager. */ - public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigFactory $config_factory, EntityManagerInterface $entity_manager, LockBackendInterface $lock, UuidInterface $uuid_service, TypedConfigManager $typed_config) { + public function __construct(StorageComparerInterface $storage_comparer, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, LockBackendInterface $lock, TypedConfigManager $typed_config) { $this->storageComparer = $storage_comparer; $this->eventDispatcher = $event_dispatcher; - $this->configFactory = $config_factory; - $this->entityManager = $entity_manager; + $this->configManager = $config_manager; $this->lock = $lock; - $this->uuidService = $uuid_service; $this->typedConfigManager = $typed_config; $this->processed = $this->storageComparer->getEmptyChangelist(); } @@ -294,7 +271,7 @@ protected function importInvokeOwner() { $handled_by_module = FALSE; // Validate the configuration object name before importing it. // Config::validateName($name); - if ($entity_type = config_get_entity_type_by_name($name)) { + if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) { $old_config = new Config($name, $this->storageComparer->getTargetStorage(), $this->eventDispatcher, $this->typedConfigManager); if ($old_data = $this->storageComparer->getTargetStorage()->read($name)) { $old_config->initWithData($old_data); @@ -307,7 +284,7 @@ protected function importInvokeOwner() { } $method = 'import' . ucfirst($op); - $handled_by_module = $this->entityManager->getStorageController($entity_type)->$method($name, $new_config, $old_config); + $handled_by_module = $this->configManager->getEntityManager()->getStorageController($entity_type)->$method($name, $new_config, $old_config); } if (!empty($handled_by_module)) { $this->setProcessed($op, $name); diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 0be3354..39f8d8a 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; class ConfigInstaller implements ConfigInstallerInterface { @@ -35,11 +34,11 @@ class ConfigInstaller implements ConfigInstallerInterface { protected $typedConfig; /** - * The entity manager. + * The configuration manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Config\ConfigManagerInterface */ - protected $entityManager; + protected $configManager; /** * The event dispatcher. @@ -57,16 +56,16 @@ class ConfigInstaller implements ConfigInstallerInterface { * The active configuration storage. * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config * The typed configuration manager. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager + * The configuration manager. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. */ - public function __construct(ConfigFactory $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, EntityManagerInterface $entity_manager, EventDispatcherInterface $event_dispatcher) { + public function __construct(ConfigFactory $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher) { $this->configFactory = $config_factory; $this->activeStorage = $active_storage; $this->typedConfig = $typed_config; - $this->entityManager = $entity_manager; + $this->configManager = $config_manager; $this->eventDispatcher = $event_dispatcher; } @@ -119,8 +118,9 @@ public function installDefaultConfig($type, $name) { if ($data !== FALSE) { $new_config->setData($data); } - if ($entity_type = config_get_entity_type_by_name($name)) { - $this->entityManager + if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) { + $this->configManager + ->getEntityManager() ->getStorageController($entity_type) ->create($new_config->get()) ->save(); diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php new file mode 100644 index 0000000..a46e3db --- /dev/null +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -0,0 +1,136 @@ +entityManager = $entity_manager; + $this->configFactory = $config_factory; + $this->typedConfigManager = $typed_config_manager; + $this->stringTranslation = $string_translation; + } + + /** + * {@inheritdoc} + */ + public function getEntityTypeIdByName($name) { + $entities = array_filter($this->entityManager->getDefinitions(), function (EntityTypeInterface $entity_type) use ($name) { + return ($config_prefix = $entity_type->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0; + }); + return key($entities); + } + + /** + * {@inheritdoc} + */ + public function getEntityManager() { + return $this->entityManager; + } + + /** + * {@inheritdoc} + */ + public function diff(StorageInterface $source_storage, StorageInterface $target_storage, $name) { + require_once DRUPAL_ROOT . '/core/lib/Drupal/Component/Diff/DiffEngine.php'; + + // The output should show configuration object differences formatted as YAML. + // But the configuration is not necessarily stored in files. Therefore, they + // need to be read and parsed, and lastly, dumped into YAML strings. + $dumper = new Dumper(); + $dumper->setIndentation(2); + + $source_data = explode("\n", $dumper->dump($source_storage->read($name), PHP_INT_MAX)); + $target_data = explode("\n", $dumper->dump($target_storage->read($name), PHP_INT_MAX)); + + // Check for new or removed files. + if ($source_data === array('false')) { + // Added file. + $source_data = array($this->stringTranslation->translate('File added')); + } + if ($target_data === array('false')) { + // Deleted file. + $target_data = array($this->stringTranslation->translate('File removed')); + } + + return new \Diff($source_data, $target_data); + } + + /** + * {@inheritdoc} + */ + function createSnapshot(StorageInterface $source_storage, StorageInterface $snapshot_storage) { + $snapshot_storage->deleteAll(); + foreach ($source_storage->listAll() as $name) { + $snapshot_storage->write($name, $source_storage->read($name)); + } + } + + /** + * Uninstalls the default configuration of a given extension. + * + * @param string $type + * The extension type; e.g., 'module' or 'theme'. + * @param string $name + * The name of the module or theme to install default configuration for. + */ + function uninstall($type, $name) { + $config_names = $this->configFactory->listAll($name . '.'); + foreach ($config_names as $config_name) { + $this->configFactory->get($config_name)->delete(); + } + $schema_dir = drupal_get_path($type, $name) . '/config/schema'; + if (is_dir($schema_dir)) { + // Refresh the schema cache if uninstalling an extension that provides + // configuration schema. + $this->typedConfigManager->clearCachedDefinitions(); + } + } +} diff --git a/core/lib/Drupal/Core/Config/ConfigManagerInterface.php b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php new file mode 100644 index 0000000..e63108d --- /dev/null +++ b/core/lib/Drupal/Core/Config/ConfigManagerInterface.php @@ -0,0 +1,71 @@ +configManager = $config_manager; $this->sourceStorage = $source_storage; $this->snapshotStorage = $snapshot_storage; } @@ -51,7 +60,7 @@ public function __construct(StorageInterface $source_storage, StorageInterface $ * The Event to process. */ public function onConfigImporterImport(ConfigImporterEvent $event) { - config_import_create_snapshot($this->sourceStorage, $this->snapshotStorage); + $this->configManager->createSnapshot($this->sourceStorage, $this->snapshotStorage); } /** diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index ef7b5e7..001e278 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -730,7 +730,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { $module_config->clear("enabled.$module")->save(); // Remove all configuration belonging to the module. - config_uninstall_default_config('module', $module); + \Drupal::service('config.manager')->uninstall('module', $module); // Update the module handler to remove the module. // The current ModuleHandler instance is obsolete with the kernel rebuild diff --git a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php index a1e8510..ee5cd4a 100644 --- a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php +++ b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php @@ -8,6 +8,7 @@ namespace Drupal\config\Controller; use Drupal\Component\Archiver\ArchiveTar; +use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Config\StorageInterface; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\system\FileDownloadController; @@ -34,6 +35,13 @@ class ConfigController implements ContainerInjectionInterface { protected $sourceStorage; /** + * The configuration manager. + * + * @var \Drupal\Core\Config\ConfigManagerInterface + */ + protected $configManager; + + /** * The file download controller. * * @var \Drupal\system\FileDownloadController @@ -47,6 +55,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.storage'), $container->get('config.storage.staging'), + $container->get('config.manager'), new FileDownloadController() ); } @@ -61,9 +70,10 @@ public static function create(ContainerInterface $container) { * @param \Drupal\system\FileDownloadController $file_download_controller * The file download controller. */ - public function __construct(StorageInterface $target_storage, StorageInterface $source_storage, FileDownloadController $file_download_controller) { + public function __construct(StorageInterface $target_storage, StorageInterface $source_storage, ConfigManagerInterface $config_manager, FileDownloadController $file_download_controller) { $this->targetStorage = $target_storage; $this->sourceStorage = $source_storage; + $this->configManager = $config_manager; $this->fileDownloadController = $file_download_controller; } @@ -94,7 +104,7 @@ public function downloadExport() { */ public function diff($config_file) { - $diff = config_diff($this->targetStorage, $this->sourceStorage, $config_file); + $diff = $this->configManager->diff($this->targetStorage, $this->sourceStorage, $config_file); $formatter = new \DrupalDiffFormatter(); $formatter->show_header = FALSE; diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php index 8e95d7e..e13eb3f 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php @@ -7,15 +7,13 @@ namespace Drupal\config\Form; -use Drupal\Component\Uuid\UuidInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Config\ConfigManagerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Config\StorageInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Config\StorageComparer; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigException; -use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Config\TypedConfigManager; use Drupal\Core\Routing\UrlGeneratorInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -55,9 +53,11 @@ class ConfigSync extends FormBase { protected $eventDispatcher; /** - * @var \Drupal\Core\Entity\EntityManagerInterface; + * The configuration manager. + * + * @var \Drupal\Core\Config\ConfigManagerInterface; */ - protected $entity_manager; + protected $configManager; /** * URL generator service. @@ -67,13 +67,6 @@ class ConfigSync extends FormBase { protected $urlGenerator; /** - * The UUID service. - * - * @var \Drupal\Component\Uuid\UuidInterface - */ - protected $uuidService; - - /** * The typed config manager. * * @var \Drupal\Core\Config\TypedConfigManager @@ -91,26 +84,20 @@ class ConfigSync extends FormBase { * The lock object. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * Event dispatcher. - * @param \Drupal\Core\Config\ConfigFactory $config_factory - * The config factory. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * Entity manager. + * @param \Drupal\Core\Config\ConfigManager + * Configuration manager. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The url generator service. - * @param \Drupal\Component\Uuid\UuidInterface $uuid_service - * The UUID Service. * @param \Drupal\Core\Config\TypedConfigManager $typed_config * The typed configuration manager. */ - public function __construct(StorageInterface $sourceStorage, StorageInterface $targetStorage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigFactory $config_factory, EntityManagerInterface $entity_manager, UrlGeneratorInterface $url_generator, UuidInterface $uuid_service, TypedConfigManager $typed_config) { + public function __construct(StorageInterface $sourceStorage, StorageInterface $targetStorage, LockBackendInterface $lock, EventDispatcherInterface $event_dispatcher, ConfigManagerInterface $config_manager, UrlGeneratorInterface $url_generator, TypedConfigManager $typed_config) { $this->sourceStorage = $sourceStorage; $this->targetStorage = $targetStorage; $this->lock = $lock; $this->eventDispatcher = $event_dispatcher; - $this->configFactory = $config_factory; - $this->entity_manager = $entity_manager; + $this->configManager = $config_manager; $this->urlGenerator = $url_generator; - $this->uuidService = $uuid_service; $this->typedConfigManager = $typed_config; } @@ -123,10 +110,8 @@ public static function create(ContainerInterface $container) { $container->get('config.storage'), $container->get('lock'), $container->get('event_dispatcher'), - $container->get('config.factory'), - $container->get('entity.manager'), + $container->get('config.manager'), $container->get('url_generator'), - $container->get('uuid'), $container->get('config.typed') ); } @@ -236,10 +221,8 @@ public function submitForm(array &$form, array &$form_state) { $config_importer = new ConfigImporter( $form_state['storage_comparer'], $this->eventDispatcher, - $this->configFactory, - $this->entity_manager, + $this->configManager, $this->lock, - $this->uuidService, $this->typedConfigManager ); if ($config_importer->alreadyImporting()) { diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigDiffTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigDiffTest.php index 5ffe662..57e0553 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigDiffTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigDiffTest.php @@ -56,7 +56,7 @@ function testDiff() { $staging->write($config_name, $staging_data); // Verify that the diff reflects a change. - $diff = config_diff($active, $staging, $config_name); + $diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $this->assertEqual($diff->edits[0]->type, 'change', 'The first item in the diff is a change.'); $this->assertEqual($diff->edits[0]->orig[0], $change_key . ': ' . $original_data[$change_key], format_string("The active value for key '%change_key' is '%original_data'.", array('%change_key' => $change_key, '%original_data' => $original_data[$change_key]))); $this->assertEqual($diff->edits[0]->closing[0], $change_key . ': ' . $change_data, format_string("The staging value for key '%change_key' is '%change_data'.", array('%change_key' => $change_key, '%change_data' => $change_data))); @@ -67,7 +67,7 @@ function testDiff() { $staging->write($config_name, $staging_data); // Verify that the diff reflects a removed key. - $diff = config_diff($active, $staging, $config_name); + $diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $this->assertEqual($diff->edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($diff->edits[1]->type, 'delete', 'The second item in the diff is a delete.'); $this->assertEqual($diff->edits[1]->orig[0], $remove_key . ': ' . $original_data[$remove_key], format_string("The active value for key '%remove_key' is '%original_data'.", array('%remove_key' => $remove_key, '%original_data' => $original_data[$remove_key]))); @@ -79,7 +79,7 @@ function testDiff() { $staging->write($config_name, $staging_data); // Verify that the diff reflects an added key. - $diff = config_diff($active, $staging, $config_name); + $diff = \Drupal::service('config.manager')->diff($active, $staging, $config_name); $this->assertEqual($diff->edits[0]->type, 'copy', 'The first item in the diff is a copy.'); $this->assertEqual($diff->edits[1]->type, 'add', 'The second item in the diff is an add.'); $this->assertFalse($diff->edits[1]->orig, format_string("The key '%add_key' does not exist in active.", array('%add_key' => $add_key))); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index ec445c5..f23cdcb 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -58,12 +58,9 @@ function setUp() { $this->configImporter = new ConfigImporter( $storage_comparer->createChangelist(), $this->container->get('event_dispatcher'), - $this->container->get('config.factory'), - $this->container->get('entity.manager'), + $this->container->get('config.manager'), $this->container->get('lock'), - $this->container->get('uuid'), - $this->container->get('config.typed'), - $this->container->get('module_handler') + $this->container->get('config.typed') ); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.staging')); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php index bd2eab5..7188744 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallTest.php @@ -76,7 +76,7 @@ function testModuleInstallation() { // Test that uninstalling configuration removes configuration schema. \Drupal::config('system.module')->set('enabled', array())->save(); - config_uninstall_default_config('module', 'config_test'); + \Drupal::service('config.manager')->uninstall('module', 'config_test'); $this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_test.schema_in_install'), 'Configuration schema for config_test.schema_in_install does not exist.'); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php index c277ac6..d8e7187 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSnapshotTest.php @@ -35,7 +35,7 @@ public function setUp() { $this->installSchema('system', 'config_snapshot'); // Update the config snapshot. This allows the parent::setUp() to write // configuration files. - config_import_create_snapshot(\Drupal::service('config.storage'), \Drupal::service('config.storage.snapshot')); + \Drupal::service('config.manager')->createSnapshot(\Drupal::service('config.storage'), \Drupal::service('config.storage.snapshot')); } /** @@ -62,7 +62,7 @@ function testSnapshot() { $this->assertTrue($active_snapshot_comparer->reset()->hasChanges()); // Update the config snapshot. - config_import_create_snapshot($active, $snapshot); + \Drupal::service('config.manager')->createSnapshot($active, $snapshot); // The snapshot and active config should now contain the same config // objects. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index b6df347..61e04d2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -1473,10 +1473,8 @@ public function configImporter() { $this->configImporter = new ConfigImporter( $storage_comparer, $this->container->get('event_dispatcher'), - $this->container->get('config.factory'), - $this->container->get('entity.manager'), + $this->container->get('config.manager'), $this->container->get('lock'), - $this->container->get('uuid'), $this->container->get('config.typed') ); }