This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 141
/
TwigCompilerPass.php
107 lines (92 loc) · 4.12 KB
/
TwigCompilerPass.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
declare(strict_types=1);
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\CoreBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* @deprecated since sonata-project/core-bundle 3.x, to be removed in 4.0.
*/
class TwigCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$this->registerFlashAliases($container);
$this->registerTwigAliases($container);
$this->forceUserToMoveConfig($container);
}
public function registerFlashAliases(ContainerBuilder $container)
{
$container
->setAlias('sonata.core.flashmessage.manager', 'sonata.twig.flashmessage.manager')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.manager" instead.'
);
$container
->setAlias('sonata.core.flashmessage.twig.runtime', 'sonata.twig.flashmessage.twig.runtime')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.twig.runtime" instead.'
);
$container
->setAlias('sonata.core.flashmessage.twig.extension', 'sonata.twig.flashmessage.twig.extension')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.flashmessage.twig.extension" instead.'
);
}
public function registerTwigAliases(ContainerBuilder $container)
{
$container
->setAlias('sonata.core.twig.extension.wrapping', 'sonata.twig.extension.wrapping')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.extension.wrapping" instead.'
);
$container
->setAlias('sonata.core.twig.status_runtime', 'sonata.twig.status_runtime')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.status_runtime" instead.'
);
$container
->setAlias('sonata.core.twig.deprecated_template_extension', 'sonata.twig.deprecated_template_extension')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.deprecated_template_extension" instead.'
);
$container
->setAlias('sonata.core.twig.template_extension', 'sonata.twig.template_extension')
->setPublic(true)
->setDeprecated(
true,
'The "%alias_id%" service is deprecated since sonata-project/core-bundle 3.19 and will be removed in 4.0. Use "sonata.twig.template_extension" instead.'
);
}
public function forceUserToMoveConfig(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
if (!isset($bundles['SonataTwigBundle'])) {
return;
}
if (!empty($container->getParameter('sonata.core.flashmessage'))) {
throw new \Exception('Move bundle config from sonata_core.flashmessage to sonata_twig.flashmessage');
}
}
}