Skip to content
Snippets Groups Projects
Verified Commit 8c8af4f3 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2366129 by andypost, stefan.r, smustgrave, vacho:...

Issue #2366129 by andypost, stefan.r, smustgrave, vacho: RegisterStreamWrappersPass and other have broken compiler pass for multiple tags
parent aafb4a44
No related branches found
No related tags found
No related merge requests found
...@@ -23,12 +23,17 @@ public function process(ContainerBuilder $container) { ...@@ -23,12 +23,17 @@ public function process(ContainerBuilder $container) {
$stream_wrapper_manager = $container->getDefinition('stream_wrapper_manager'); $stream_wrapper_manager = $container->getDefinition('stream_wrapper_manager');
$services = []; $services = [];
foreach ($container->findTaggedServiceIds('stream_wrapper') as $id => $attributes) { foreach ($container->findTaggedServiceIds('stream_wrapper') as $id => $tags) {
$class = $container->getDefinition($id)->getClass(); $class = $container->getDefinition($id)->getClass();
$scheme = $attributes[0]['scheme']; // Loop through all the tags for this stream wrapper as we may have
// multiple schemes.
$stream_wrapper_manager->addMethodCall('addStreamWrapper', [$id, $class, $scheme]); foreach ($tags as $attributes) {
$stream_wrapper_manager->addMethodCall('addStreamWrapper', [
$id,
$class,
$attributes['scheme'],
]);
}
$services[$id] = new Reference($id); $services[$id] = new Reference($id);
} }
$stream_wrapper_manager->addArgument(ServiceLocatorTagPass::register($container, $services)); $stream_wrapper_manager->addArgument(ServiceLocatorTagPass::register($container, $services));
......
...@@ -15,3 +15,8 @@ services: ...@@ -15,3 +15,8 @@ services:
class: Drupal\file_test\StreamWrapper\DummyExternalReadOnlyWrapper class: Drupal\file_test\StreamWrapper\DummyExternalReadOnlyWrapper
tags: tags:
- { name: stream_wrapper, scheme: dummy-external-readonly } - { name: stream_wrapper, scheme: dummy-external-readonly }
stream_wrapper.dummy_multiple:
class: Drupal\file_test\StreamWrapper\DummyMultipleStreamWrapper
tags:
- { name: stream_wrapper, scheme: dummy1 }
- { name: stream_wrapper, scheme: dummy2 }
<?php
namespace Drupal\file_test\StreamWrapper;
/**
* Helper class for testing the stream wrapper registry.
*
* Dummy stream wrapper implementation (dummy1://, dummy2://).
*/
class DummyMultipleStreamWrapper extends DummyStreamWrapper {}
...@@ -324,6 +324,8 @@ public function testModuleStreamWrappers() { ...@@ -324,6 +324,8 @@ public function testModuleStreamWrappers() {
file_exists('dummy://'); file_exists('dummy://');
$stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(); $stream_wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers();
$this->assertTrue(isset($stream_wrappers['dummy'])); $this->assertTrue(isset($stream_wrappers['dummy']));
$this->assertTrue(isset($stream_wrappers['dummy1']));
$this->assertTrue(isset($stream_wrappers['dummy2']));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment