forked from phpmentors-jp/pageflower-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReplaceSessionDefinitionPass.php
40 lines (35 loc) · 1.52 KB
/
ReplaceSessionDefinitionPass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/*
* Copyright (c) Atsuhiro Kubo <kubo@iteman.jp>,
* All rights reserved.
*
* This file is part of PHPMentorsPageflowerBundle.
*
* This program and the accompanying materials are made available under
* the terms of the BSD 2-Clause License which accompanies this
* distribution, and is available at http://opensource.org/licenses/BSD-2-Clause
*/
namespace PHPMentors\PageflowerBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class ReplaceSessionDefinitionPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{
$conversationalSessionDefinition = $container->getDefinition('phpmentors_pageflower.conversational_session');
$sessionDefinition = $container->getDefinition('session');
/*
* As of version 3.4.39, the 'session.attribute_bag' and 'session.flash_bag' arguments have been removed from the 'session' definition.
* See https://github.com/symfony/symfony/pull/36063 for more details.
*/
if (count($sessionDefinition->getArguments()) == 1) {
$conversationalSessionDefinition->replaceArgument(1, null);
$conversationalSessionDefinition->replaceArgument(2, null);
}
$container->setDefinition('session', $conversationalSessionDefinition);
$container->removeDefinition('phpmentors_pageflower.conversational_session');
}
}