diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 968192e..3f1f2f6 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -327,7 +327,6 @@ function install_begin_request(&$install_state) { // Register the stream wrapper manager. $container ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager') - ->addArgument(new Reference('module_handler')) ->addMethodCall('setContainer', array(new Reference('service_container'))); \Drupal::setContainer($container); diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php index aa985ed..9c569bb 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php @@ -63,15 +63,26 @@ class StreamWrapperManager extends ContainerAware { protected $configFactory; /** - * Constructs a StreamWrapperManager object. + * Sets the event dispatcher. + * + * The alter event will only be triggered if an event dispatcher is present. * * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher * The event dispatcher + */ + public function setEventDispatcher(EventDispatcherInterface $dispatcher) { + $this->dispatcher = $dispatcher; + } + + /** + * Sets the config factory. + * + * This is necessary to make the private file system available. + * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ - public function __construct(EventDispatcherInterface $dispatcher, ConfigFactoryInterface $config_factory) { - $this->dispatcher = $dispatcher; + public function setConfigFactory(ConfigFactoryInterface $config_factory) { $this->configFactory = $config_factory; } @@ -288,13 +299,14 @@ public function addStreamWrapper($service_id, $class, $scheme) { * Internal use only. */ public function register() { - $event = new StreamWrapperAlterEvent($this->info); - // Only expose the private file stream wrapper if a file path has been set. - if (!$this->configFactory->get('system.file')->get('path.private')) { + if (!$this->configFactory || !$this->configFactory->get('system.file')->get('path.private')) { unset($this->info['private']); } - $this->info = $this->dispatcher->dispatch(StreamWrapperEvents::ALTER, $event)->getStreamWrappers(); + if ($this->dispatcher) { + $event = new StreamWrapperAlterEvent($this->info); + $this->info = $this->dispatcher->dispatch(StreamWrapperEvents::ALTER, $event)->getStreamWrappers(); + } foreach ($this->info as $scheme => $info) { $this->registerWrapper($scheme, $info['class'], $info['type']); diff --git a/core/modules/simpletest/src/KernelTestBase.php b/core/modules/simpletest/src/KernelTestBase.php index f26c5d4..6b91638 100644 --- a/core/modules/simpletest/src/KernelTestBase.php +++ b/core/modules/simpletest/src/KernelTestBase.php @@ -314,7 +314,7 @@ public function containerBuild(ContainerBuilder $container) { // Register the stream wrapper manager. $container ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager') - ->addArgument(new Reference('module_handler')) + ->addMethodCall('setConfigFactory', array(new Reference('config.factory'))) ->addMethodCall('setContainer', array(new Reference('service_container'))); $request = Request::create('/');