vendor/symfony/mercure-bundle/src/MercureBundle.php line 25

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Mercure Component project.
  4.  *
  5.  * (c) Kévin Dunglas <dunglas@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Symfony\Bundle\MercureBundle;
  12. use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
  13. use Symfony\Component\DependencyInjection\Compiler\PassConfig;
  14. use Symfony\Component\DependencyInjection\ContainerBuilder;
  15. use Symfony\Component\HttpKernel\Bundle\Bundle;
  16. use Symfony\Component\Mercure\Authorization;
  17. /**
  18.  * @author Kévin Dunglas <dunglas@gmail.com>
  19.  */
  20. final class MercureBundle extends Bundle
  21. {
  22.     public function build(ContainerBuilder $container): void
  23.     {
  24.         parent::build($container);
  25.         $container->addCompilerPass(new class() implements CompilerPassInterface {
  26.             public function process(ContainerBuilder $container): void
  27.             {
  28.                 if (!$container->hasDefinition(Authorization::class)) {
  29.                     return;
  30.                 }
  31.                 $definition $container->getDefinition(Authorization::class);
  32.                 if (
  33.                     null === $definition->getArgument(1) &&
  34.                     $container->hasParameter('session.storage.options')
  35.                 ) {
  36.                     $definition->setArgument(
  37.                         1,
  38.                         $container->getParameter('session.storage.options')['cookie_lifetime'] ?? null
  39.                     );
  40.                 }
  41.             }
  42.         }, PassConfig::TYPE_BEFORE_REMOVING);
  43.     }
  44. }