File tree Expand file tree Collapse file tree 3 files changed +48
-2
lines changed
DependencyInjection/Compiler Expand file tree Collapse file tree 3 files changed +48
-2
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <
[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
13
+
14
+ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
16
+ use Symfony\Component\DependencyInjection\Definition;
17
+ use Symfony\Component\DependencyInjection\Reference;
18
+
19
+ class AssetsContextPass implements CompilerPassInterface
20
+ {
21
+ public function process(ContainerBuilder $container)
22
+ {
23
+ if (!$container->hasDefinition('assets.context')) {
24
+ return;
25
+ }
26
+
27
+ if (!$container->hasDefinition('router.request_context')) {
28
+ $container->setParameter('asset.request_context.base_path', $container->getParameter('asset.request_context.base_path') ?? '');
29
+ $container->setParameter('asset.request_context.secure', $container->getParameter('asset.request_context.secure') ?? false);
30
+
31
+ return;
32
+ }
33
+
34
+ $context = $container->getDefinition('assets.context');
35
+
36
+ if (null === $container->getParameter('asset.request_context.base_path')) {
37
+ $context->replaceArgument(1, (new Definition('string'))->setFactory([new Reference('router.request_context'), 'getBaseUrl']));
38
+ }
39
+
40
+ if (null === $container->getParameter('asset.request_context.secure')) {
41
+ $context->replaceArgument(2, (new Definition('bool'))->setFactory([new Reference('router.request_context'), 'isSecure']));
42
+ }
43
+ }
44
+ }
Original file line number Diff line number Diff line change 14
14
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
15
15
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass;
16
16
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
17
+ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AssetsContextPass;
17
18
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
18
19
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
19
20
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
@@ -120,6 +121,7 @@ public function build(ContainerBuilder $container)
120
121
]);
121
122
}
122
123
124
+ $container->addCompilerPass(new AssetsContextPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION);
123
125
$container->addCompilerPass(new LoggerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
124
126
$container->addCompilerPass(new RegisterControllerArgumentLocatorsPass());
125
127
$container->addCompilerPass(new RemoveEmptyControllerArgumentLocatorsPass(), PassConfig::TYPE_BEFORE_REMOVING);
Original file line number Diff line number Diff line change 5
5
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
6
6
7
7
<parameters>
8
- <parameter key="asset.request_context.base_path"></parameter>
9
- <parameter key="asset.request_context.secure">false </parameter>
8
+ <parameter key="asset.request_context.base_path">null </parameter>
9
+ <parameter key="asset.request_context.secure">null </parameter>
10
10
</parameters>
11
11
12
12
<services>
You can’t perform that action at this time.
0 commit comments