Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / lib / Drupal / Core / DependencyInjection / Compiler / RegisterStreamWrappersPass.php
1 <?php
2
3 namespace Drupal\Core\DependencyInjection\Compiler;
4
5 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6 use Symfony\Component\DependencyInjection\ContainerBuilder;
7
8 /**
9  * Adds services tagged 'stream_wrapper' to the stream_wrapper_manager service.
10  */
11 class RegisterStreamWrappersPass implements CompilerPassInterface {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function process(ContainerBuilder $container) {
17     if (!$container->hasDefinition('stream_wrapper_manager')) {
18       return;
19     }
20
21     $stream_wrapper_manager = $container->getDefinition('stream_wrapper_manager');
22
23     foreach ($container->findTaggedServiceIds('stream_wrapper') as $id => $attributes) {
24       $class = $container->getDefinition($id)->getClass();
25       $scheme = $attributes[0]['scheme'];
26
27       $stream_wrapper_manager->addMethodCall('addStreamWrapper', [$id, $class, $scheme]);
28     }
29   }
30
31 }