Loading core/.phpstan-baseline.php +0 −6 Original line number Diff line number Diff line Loading @@ -10159,12 +10159,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\StreamWrapper\\\\StreamWrapperManager\\:\\:addStreamWrapper\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\StreamWrapper\\\\StreamWrapperManager\\:\\:register\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', core/core.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -1554,6 +1554,7 @@ services: Drupal\Core\Render\ElementInfoManagerInterface: '@plugin.manager.element_info' stream_wrapper_manager: class: Drupal\Core\StreamWrapper\StreamWrapperManager autowire: true Drupal\Core\StreamWrapper\StreamWrapperManagerInterface: '@stream_wrapper_manager' stream_wrapper.assets: class: Drupal\Core\StreamWrapper\AssetsStream Loading core/lib/Drupal/Core/CoreServiceProvider.php +0 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ use Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass; use Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass; use Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass; use Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass; use Drupal\Core\DependencyInjection\Compiler\StackedKernelPass; use Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass; use Drupal\Core\DependencyInjection\Compiler\SuperUserAccessPolicyPass; Loading Loading @@ -91,7 +90,6 @@ public function register(ContainerBuilder $container) { // Collect tagged handler services as method calls on consumer services. $container->addCompilerPass(new TaggedHandlersPass()); $container->addCompilerPass(new RegisterStreamWrappersPass()); $container->addCompilerPass(new TwigExtensionPass()); // Add a compiler pass for registering event subscribers. Loading core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.phpdeleted 100644 → 0 +0 −42 Original line number Diff line number Diff line <?php namespace Drupal\Core\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * Adds services tagged 'stream_wrapper' to the stream_wrapper_manager service. */ class RegisterStreamWrappersPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('stream_wrapper_manager')) { return; } $stream_wrapper_manager = $container->getDefinition('stream_wrapper_manager'); $services = []; foreach ($container->findTaggedServiceIds('stream_wrapper') as $id => $tags) { $class = $container->getDefinition($id)->getClass(); // Loop through all the tags for this stream wrapper as we may have // multiple schemes. foreach ($tags as $attributes) { $stream_wrapper_manager->addMethodCall('addStreamWrapper', [ $id, $class, $attributes['scheme'], ]); } $services[$id] = new Reference($id); } $stream_wrapper_manager->addArgument(ServiceLocatorTagPass::register($container, $services)); } } core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +13 −43 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ namespace Drupal\Core\StreamWrapper; use Drupal\Core\Site\Settings; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Attribute\AutowireLocator; use Symfony\Component\DependencyInjection\ServiceLocator; /** * Provides a StreamWrapper manager. Loading @@ -15,24 +16,14 @@ class StreamWrapperManager implements StreamWrapperManagerInterface { /** * Constructs a StreamWrapperManager object. * * @param \Psr\Container\ContainerInterface $container * The stream wrapper service locator. * @param \Symfony\Component\DependencyInjection\ServiceLocator $container * A service locator containing stream wrapper services, keyed by scheme. */ public function __construct( protected readonly ContainerInterface $container, #[AutowireLocator('stream_wrapper', indexAttribute: 'scheme')] protected readonly ServiceLocator $container, ) {} /** * Contains stream wrapper info. * * An associative array where keys are scheme names and values are themselves * associative arrays with the keys class, type and (optionally) service_id, * and string values. * * @var array */ protected $info = []; /** * Contains collected stream wrappers. * Loading @@ -42,7 +33,6 @@ public function __construct( * - class: stream wrapper class name * - type: a bitmask corresponding to the type constants in * StreamWrapperInterface * - service_id: name of service * * The array on key StreamWrapperInterface::ALL contains representations of * all schemes and corresponding wrappers. Loading Loading @@ -116,10 +106,9 @@ public function getViaUri($uri) { * {@inheritdoc} */ public function getClass($scheme) { if (isset($this->info[$scheme])) { return $this->info[$scheme]['class']; if ($this->container->has($scheme)) { return get_class($this->container->get($scheme)); } return FALSE; } Loading @@ -135,8 +124,8 @@ public function getClass($scheme) { * A stream wrapper object, or false if the scheme is not available. */ protected function getWrapper($scheme, $uri) { if (isset($this->info[$scheme]['service_id'])) { $instance = $this->container->get($this->info[$scheme]['service_id']); if ($this->container->has($scheme)) { $instance = $this->container->get($scheme); $instance->setUri($uri); return $instance; } Loading @@ -144,34 +133,15 @@ protected function getWrapper($scheme, $uri) { return FALSE; } /** * Adds a stream wrapper. * * Internal use only. * * @param string $service_id * The service id. * @param string $class * The stream wrapper class. * @param string $scheme * The scheme for which the wrapper should be registered. */ public function addStreamWrapper($service_id, $class, $scheme) { $this->info[$scheme] = [ 'class' => $class, 'type' => $class::getType(), 'service_id' => $service_id, ]; } /** * Registers the tagged stream wrappers. * * Internal use only. */ public function register() { foreach ($this->info as $scheme => $info) { $this->registerWrapper($scheme, $info['class'], $info['type']); foreach (array_keys($this->container->getProvidedServices()) as $scheme) { $class = $this->getClass($scheme); $this->registerWrapper($scheme, $class, $class::getType()); } } Loading Loading
core/.phpstan-baseline.php +0 −6 Original line number Diff line number Diff line Loading @@ -10159,12 +10159,6 @@ 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/StreamWrapper/StreamWrapperInterface.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\StreamWrapper\\\\StreamWrapperManager\\:\\:addStreamWrapper\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', 'count' => 1, 'path' => __DIR__ . '/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php', ]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\Core\\\\StreamWrapper\\\\StreamWrapperManager\\:\\:register\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return',
core/core.services.yml +1 −0 Original line number Diff line number Diff line Loading @@ -1554,6 +1554,7 @@ services: Drupal\Core\Render\ElementInfoManagerInterface: '@plugin.manager.element_info' stream_wrapper_manager: class: Drupal\Core\StreamWrapper\StreamWrapperManager autowire: true Drupal\Core\StreamWrapper\StreamWrapperManagerInterface: '@stream_wrapper_manager' stream_wrapper.assets: class: Drupal\Core\StreamWrapper\AssetsStream Loading
core/lib/Drupal/Core/CoreServiceProvider.php +0 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ use Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass; use Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass; use Drupal\Core\DependencyInjection\Compiler\RegisterServicesForDestructionPass; use Drupal\Core\DependencyInjection\Compiler\RegisterStreamWrappersPass; use Drupal\Core\DependencyInjection\Compiler\StackedKernelPass; use Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass; use Drupal\Core\DependencyInjection\Compiler\SuperUserAccessPolicyPass; Loading Loading @@ -91,7 +90,6 @@ public function register(ContainerBuilder $container) { // Collect tagged handler services as method calls on consumer services. $container->addCompilerPass(new TaggedHandlersPass()); $container->addCompilerPass(new RegisterStreamWrappersPass()); $container->addCompilerPass(new TwigExtensionPass()); // Add a compiler pass for registering event subscribers. Loading
core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.phpdeleted 100644 → 0 +0 −42 Original line number Diff line number Diff line <?php namespace Drupal\Core\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; /** * Adds services tagged 'stream_wrapper' to the stream_wrapper_manager service. */ class RegisterStreamWrappersPass implements CompilerPassInterface { /** * {@inheritdoc} */ public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('stream_wrapper_manager')) { return; } $stream_wrapper_manager = $container->getDefinition('stream_wrapper_manager'); $services = []; foreach ($container->findTaggedServiceIds('stream_wrapper') as $id => $tags) { $class = $container->getDefinition($id)->getClass(); // Loop through all the tags for this stream wrapper as we may have // multiple schemes. foreach ($tags as $attributes) { $stream_wrapper_manager->addMethodCall('addStreamWrapper', [ $id, $class, $attributes['scheme'], ]); } $services[$id] = new Reference($id); } $stream_wrapper_manager->addArgument(ServiceLocatorTagPass::register($container, $services)); } }
core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +13 −43 Original line number Diff line number Diff line Loading @@ -3,7 +3,8 @@ namespace Drupal\Core\StreamWrapper; use Drupal\Core\Site\Settings; use Psr\Container\ContainerInterface; use Symfony\Component\DependencyInjection\Attribute\AutowireLocator; use Symfony\Component\DependencyInjection\ServiceLocator; /** * Provides a StreamWrapper manager. Loading @@ -15,24 +16,14 @@ class StreamWrapperManager implements StreamWrapperManagerInterface { /** * Constructs a StreamWrapperManager object. * * @param \Psr\Container\ContainerInterface $container * The stream wrapper service locator. * @param \Symfony\Component\DependencyInjection\ServiceLocator $container * A service locator containing stream wrapper services, keyed by scheme. */ public function __construct( protected readonly ContainerInterface $container, #[AutowireLocator('stream_wrapper', indexAttribute: 'scheme')] protected readonly ServiceLocator $container, ) {} /** * Contains stream wrapper info. * * An associative array where keys are scheme names and values are themselves * associative arrays with the keys class, type and (optionally) service_id, * and string values. * * @var array */ protected $info = []; /** * Contains collected stream wrappers. * Loading @@ -42,7 +33,6 @@ public function __construct( * - class: stream wrapper class name * - type: a bitmask corresponding to the type constants in * StreamWrapperInterface * - service_id: name of service * * The array on key StreamWrapperInterface::ALL contains representations of * all schemes and corresponding wrappers. Loading Loading @@ -116,10 +106,9 @@ public function getViaUri($uri) { * {@inheritdoc} */ public function getClass($scheme) { if (isset($this->info[$scheme])) { return $this->info[$scheme]['class']; if ($this->container->has($scheme)) { return get_class($this->container->get($scheme)); } return FALSE; } Loading @@ -135,8 +124,8 @@ public function getClass($scheme) { * A stream wrapper object, or false if the scheme is not available. */ protected function getWrapper($scheme, $uri) { if (isset($this->info[$scheme]['service_id'])) { $instance = $this->container->get($this->info[$scheme]['service_id']); if ($this->container->has($scheme)) { $instance = $this->container->get($scheme); $instance->setUri($uri); return $instance; } Loading @@ -144,34 +133,15 @@ protected function getWrapper($scheme, $uri) { return FALSE; } /** * Adds a stream wrapper. * * Internal use only. * * @param string $service_id * The service id. * @param string $class * The stream wrapper class. * @param string $scheme * The scheme for which the wrapper should be registered. */ public function addStreamWrapper($service_id, $class, $scheme) { $this->info[$scheme] = [ 'class' => $class, 'type' => $class::getType(), 'service_id' => $service_id, ]; } /** * Registers the tagged stream wrappers. * * Internal use only. */ public function register() { foreach ($this->info as $scheme => $info) { $this->registerWrapper($scheme, $info['class'], $info['type']); foreach (array_keys($this->container->getProvidedServices()) as $scheme) { $class = $this->getClass($scheme); $this->registerWrapper($scheme, $class, $class::getType()); } } Loading