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.                 $definition $container->getDefinition(Authorization::class);
  29.                 if (
  30.                     null === $definition->getArgument(1) &&
  31.                     $container->hasParameter('session.storage.options')
  32.                 ) {
  33.                     $definition->setArgument(
  34.                         2,
  35.                         $container->getParameter('session.storage.options')['cookie_lifetime'] ?? null
  36.                     );
  37.                 }
  38.             }
  39.         }, PassConfig::TYPE_BEFORE_REMOVING);
  40.     }
  41. }