diff --git a/core/core.services.yml b/core/core.services.yml index b832314..926741f 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -237,7 +237,7 @@ services: - { name: event_subscriber } config.installer: class: Drupal\Core\Config\ConfigInstaller - arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher'] + arguments: ['@config.factory', '@config.storage', '@config.typed', '@config.manager', '@event_dispatcher', '%install_profile%'] lazy: true config.storage: class: Drupal\Core\Config\CachedStorage diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 7153ab9..56a1a9d 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -65,6 +65,13 @@ class ConfigInstaller implements ConfigInstallerInterface { protected $isSyncing = FALSE; /** + * The name of the currently active installation profile. + * + * @var string + */ + protected $installProfile; + + /** * Constructs the configuration installer. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory @@ -77,13 +84,16 @@ class ConfigInstaller implements ConfigInstallerInterface { * The configuration manager. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. + * @param string $install_profile + * The name of the currently active installation profile. */ - public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher) { + public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher, $install_profile) { $this->configFactory = $config_factory; $this->activeStorages[$active_storage->getCollectionName()] = $active_storage; $this->typedConfig = $typed_config; $this->configManager = $config_manager; $this->eventDispatcher = $event_dispatcher; + $this->installProfile = $install_profile; } /** @@ -121,7 +131,7 @@ public function installDefaultConfig($type, $name) { $config_to_create = $this->getConfigToCreate($storage, $collection, $prefix, $profile_storage); // If we're installing a profile ensure configuration that is overriding // is excluded. - if ($name == $this->drupalGetProfile()) { + if ($name == $this->installProfile) { $existing_configuration = $this->getActiveStorages($collection)->listAll(); $config_to_create = array_diff_key($config_to_create, array_flip($existing_configuration)); } @@ -156,16 +166,15 @@ public function installDefaultConfig($type, $name) { * {@inheritdoc} */ public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = []) { - $profile = $this->drupalGetProfile(); if (!$storage) { // Search the install profile's optional configuration too. $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE); // The extension install storage ensures that overrides are used. $profile_storage = NULL; } - elseif (isset($profile)) { + elseif (isset($this->installProfile)) { // Creates a profile storage to search for overrides. - $profile_install_path = $this->drupalGetPath('module', $profile) . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; + $profile_install_path = $this->drupalGetPath('module', $this->installProfile) . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; $profile_storage = new FileStorage($profile_install_path, StorageInterface::DEFAULT_COLLECTION); } else { @@ -442,7 +451,7 @@ public function checkConfigurationToInstall($type, $name) { // Install profiles can not have config clashes. Configuration that // has the same name as a module's configuration will be used instead. - if ($name != $this->drupalGetProfile()) { + if ($name != $this->installProfile) { // Throw an exception if the module being installed contains configuration // that already exists. Additionally, can not continue installing more // modules because those may depend on the current module being installed. @@ -556,11 +565,10 @@ protected function getEnabledExtensions() { * used. */ protected function getProfileStorage($installing_name = '') { - $profile = $this->drupalGetProfile(); - if ($this->drupalInstallationAttempted() && $profile != $installing_name) { + if (isset($this->installProfile) && $this->drupalInstallationAttempted() && $this->installProfile != $installing_name) { // Profiles should not contain optional configuration so always use the // install directory. - $profile_install_path = $this->getDefaultConfigDirectory('module', $profile); + $profile_install_path = $this->getDefaultConfigDirectory('module', $this->installProfile); $profile_storage = new FileStorage($profile_install_path, StorageInterface::DEFAULT_COLLECTION); } else { @@ -603,20 +611,6 @@ protected function drupalGetPath($type, $name) { } /** - * Gets the install profile from settings. - * - * @return string|null $profile - * The name of the installation profile or NULL if no installation profile - * is currently active. This is the case for example during the first steps - * of the installer or during unit tests. - */ - protected function drupalGetProfile() { - // Settings is safe to use because settings.php is written before any module - // is installed. - return \Drupal::installProfile(); - } - - /** * Wrapper for drupal_installation_attempted(). * * @return bool diff --git a/core/lib/Drupal/Core/InstallProfileFactory.php b/core/lib/Drupal/Core/InstallProfileFactory.php deleted file mode 100644 index dc6b9af..0000000 --- a/core/lib/Drupal/Core/InstallProfileFactory.php +++ /dev/null @@ -1,42 +0,0 @@ -drupalKernel = $drupal_kernel; - } - - /** - * Gets the install profile. - * - * @return string - */ - public function get() { - return $this->drupalKernel->getInstallProfile(); - } - -} -