diff --git a/core/core.services.yml b/core/core.services.yml index 738b059..da32425 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -86,6 +86,7 @@ services: arguments: ['@config.factory', '@config.storage', '@config.typed', '@entity.manager', '@event_dispatcher'] config.preload_subscriber: class: Drupal\Core\Config\ConfigPreloadSubscriber + arguments: ['@settings'] tags: - { name: event_subscriber } config.storage.staging: diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 97ab555..953e52d 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -195,8 +195,8 @@ public function loadMultiple(array $names) { global $conf; if (!$this->preloadEventFired) { - $this->preloadEventFired = TRUE; $names = array_unique($names + $this->getPreloadNames()); + $this->preloadEventFired = TRUE; } $list = array(); diff --git a/core/lib/Drupal/Core/Config/ConfigPreloadEvent.php b/core/lib/Drupal/Core/Config/ConfigPreloadEvent.php index e314786..738ecd7 100644 --- a/core/lib/Drupal/Core/Config/ConfigPreloadEvent.php +++ b/core/lib/Drupal/Core/Config/ConfigPreloadEvent.php @@ -38,7 +38,7 @@ public function getNames() { * @param array $names * The configuration object names to preload. * - * @return self + * @return $this * The ConfigPreloadEvent object. */ public function addNames(array $names) { @@ -53,7 +53,7 @@ public function addNames(array $names) { * @param array $names_to_remove * The configuration object names remove preload. * - * @return self + * @return $this * The ConfigPreloadEvent object. */ public function removeNames(array $names_to_remove) { @@ -62,4 +62,3 @@ public function removeNames(array $names_to_remove) { } } - diff --git a/core/lib/Drupal/Core/Config/ConfigPreloadSubscriber.php b/core/lib/Drupal/Core/Config/ConfigPreloadSubscriber.php index 959d568..31e82eb 100644 --- a/core/lib/Drupal/Core/Config/ConfigPreloadSubscriber.php +++ b/core/lib/Drupal/Core/Config/ConfigPreloadSubscriber.php @@ -8,7 +8,6 @@ use Drupal\Component\Utility\Settings; use Drupal\Core\Config\ConfigPreloadEvent; -use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -17,24 +16,39 @@ class ConfigPreloadSubscriber implements EventSubscriberInterface { /** - * Returns the names of any configuration objects in Settings. + * @var \Drupal\Component\Utility\Settings + * The settings service. + */ + protected $settings; + + /** + * Creates a config preload subscriber. + * + * @param \Drupal\Component\Utility\Settings $settings + * The settings service. + */ + public function __construct(Settings $settings) { + $this->settings = $settings; + } + + /** + * Adds the names of any configuration objects in Settings to the event. * * @param \Drupal\Core\Config\ConfigPreloadEvent $event * Configuration preload event to respond to. */ public function onConfigPreloadNamesGetSettingsNames(ConfigPreloadEvent $event) { - $settings_config_names = Settings::getSingleton()->get('config_preload_names', array()); + $settings_config_names = $this->settings->get('config_preload_names', array()); if ($settings_config_names) { $event->addNames($settings_config_names); } } /** - * Implements EventSubscriberInterface::getSubscribedEvents(). + * {@inheritdoc} */ - static function getSubscribedEvents() { + public static function getSubscribedEvents() { $events['config.preload.names'][] = array('onConfigPreloadNamesGetSettingsNames', 48); return $events; } } -