Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. StackedSessionHandlerPass.php

class StackedSessionHandlerPass

Provides a compiler pass for stacked session save handlers.

Hierarchy

  • class \Drupal\Core\DependencyInjection\Compiler\StackedSessionHandlerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface

Expanded class hierarchy of StackedSessionHandlerPass

1 file declares its use of StackedSessionHandlerPass
CoreServiceProvider.php in core/lib/Drupal/Core/CoreServiceProvider.php

File

core/lib/Drupal/Core/DependencyInjection/Compiler/StackedSessionHandlerPass.php, line 12

Namespace

Drupal\Core\DependencyInjection\Compiler
View source
class StackedSessionHandlerPass implements CompilerPassInterface {
    
    /**
     * {@inheritdoc}
     */
    public function process(ContainerBuilder $container) : void {
        if ($container->hasDefinition('session_handler')) {
            return;
        }
        $session_handler_proxies = [];
        $priorities = [];
        foreach ($container->findTaggedServiceIds('session_handler_proxy') as $id => $attributes) {
            $priorities[$id] = $attributes[0]['priority'] ?? 0;
            $session_handler_proxies[$id] = $container->getDefinition($id);
        }
        array_multisort($priorities, SORT_ASC, $session_handler_proxies);
        $decorated_id = 'session_handler.storage';
        foreach ($session_handler_proxies as $id => $decorator) {
            // Prepend the inner session handler as first constructor argument.
            $arguments = $decorator->getArguments();
            array_unshift($arguments, new Reference($decorated_id));
            $decorator->setArguments($arguments);
            $decorated_id = $id;
        }
        $container->setAlias('session_handler', $decorated_id);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
StackedSessionHandlerPass::process public function You can modify the container here before it is dumped to PHP code. Overrides CompilerPassInterface::process

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal