Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee73cf2

Browse files
committed
revert changes to unaffected code
1 parent b9bbcf2 commit ee73cf2

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

core-bundle/src/ContaoCoreBundle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
use Contao\CoreBundle\DependencyInjection\Compiler\RegisterHookListenersPass;
2828
use Contao\CoreBundle\DependencyInjection\Compiler\RegisterPagesPass;
2929
use Contao\CoreBundle\DependencyInjection\Compiler\RemembermeServicesPass;
30+
use Contao\CoreBundle\DependencyInjection\Compiler\RewireTwigPathsPass;
3031
use Contao\CoreBundle\DependencyInjection\Compiler\SearchIndexerPass;
3132
use Contao\CoreBundle\DependencyInjection\Compiler\TaggedMigrationsPass;
3233
use Contao\CoreBundle\DependencyInjection\Compiler\TranslationDataCollectorPass;
33-
use Contao\CoreBundle\DependencyInjection\Compiler\TwigPathsPass;
3434
use Contao\CoreBundle\DependencyInjection\ContaoCoreExtension;
3535
use Contao\CoreBundle\DependencyInjection\Security\ContaoLoginFactory;
3636
use Contao\CoreBundle\Event\ContaoCoreEvents;
@@ -116,7 +116,7 @@ public function build(ContainerBuilder $container): void
116116
$container->addCompilerPass(new AddCronJobsPass());
117117
$container->addCompilerPass(new AddAvailableTransportsPass());
118118
$container->addCompilerPass(new RegisterRouteEnhancersPass('contao.routing.page_router', 'contao.page_router_enhancer'));
119-
$container->addCompilerPass(new TwigPathsPass());
119+
$container->addCompilerPass(new RewireTwigPathsPass());
120120
$container->addCompilerPass(new AddNativeTransportFactoryPass());
121121
}
122122
}

core-bundle/src/DependencyInjection/Compiler/TwigPathsPass.php renamed to core-bundle/src/DependencyInjection/Compiler/RewireTwigPathsPass.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,24 @@
1515
use Contao\CoreBundle\Twig\Loader\FailTolerantFilesystemLoader;
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1717
use Symfony\Component\DependencyInjection\ContainerBuilder;
18-
use Symfony\Component\DependencyInjection\Definition;
1918

2019
/**
2120
* @internal
2221
*/
23-
class TwigPathsPass implements CompilerPassInterface
22+
class RewireTwigPathsPass implements CompilerPassInterface
2423
{
25-
public function process(ContainerBuilder $container): void
26-
{
27-
$this->migrateSymfonyTwigPaths(
28-
$container->getDefinition('twig.loader.native_filesystem'),
29-
$container->getDefinition(FailTolerantFilesystemLoader::class)
30-
);
31-
}
32-
3324
/**
3425
* Rewires Symfony's "addPath" method calls to our fail tolerant version
35-
* of a filesystem loader which tolerates missing paths that will occur
26+
* of a filesystem loader which tolerates missing paths. Those will occur
3627
* as soon as a user removes registered directories (e.g. from within the
37-
* backend) and that would otherwise require the container to be rebuild.
28+
* backend) and that would otherwise require the container to be rebuilt.
3829
*/
39-
private function migrateSymfonyTwigPaths(Definition $from, Definition $to): void
30+
public function process(ContainerBuilder $container): void
4031
{
32+
$original = $container->getDefinition('twig.loader.native_filesystem');
33+
4134
$calls = array_filter(
42-
$from->getMethodCalls(),
35+
$original->getMethodCalls(),
4336
static function (array $call): bool {
4437
return 'addPath' === $call[0];
4538
}
@@ -49,10 +42,12 @@ static function (array $call): bool {
4942
return;
5043
}
5144

52-
$from->removeMethodCall('addPath');
45+
$original->removeMethodCall('addPath');
46+
47+
$replaced = $container->getDefinition(FailTolerantFilesystemLoader::class);
5348

5449
foreach ($calls as $call) {
55-
$to->addMethodCall(...$call);
50+
$replaced->addMethodCall(...$call);
5651
}
5752
}
5853
}

core-bundle/tests/ContaoCoreBundleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
use Contao\CoreBundle\DependencyInjection\Compiler\RegisterHookListenersPass;
2929
use Contao\CoreBundle\DependencyInjection\Compiler\RegisterPagesPass;
3030
use Contao\CoreBundle\DependencyInjection\Compiler\RemembermeServicesPass;
31+
use Contao\CoreBundle\DependencyInjection\Compiler\RewireTwigPathsPass;
3132
use Contao\CoreBundle\DependencyInjection\Compiler\SearchIndexerPass;
3233
use Contao\CoreBundle\DependencyInjection\Compiler\TaggedMigrationsPass;
3334
use Contao\CoreBundle\DependencyInjection\Compiler\TranslationDataCollectorPass;
34-
use Contao\CoreBundle\DependencyInjection\Compiler\TwigPathsPass;
3535
use Contao\CoreBundle\DependencyInjection\Security\ContaoLoginFactory;
3636
use Contao\CoreBundle\Event\ContaoCoreEvents;
3737
use Contao\CoreBundle\Event\GenerateSymlinksEvent;
@@ -73,7 +73,7 @@ public function testAddsTheCompilerPasses(): void
7373
AddCronJobsPass::class,
7474
AddAvailableTransportsPass::class,
7575
RegisterRouteEnhancersPass::class,
76-
TwigPathsPass::class,
76+
RewireTwigPathsPass::class,
7777
AddNativeTransportFactoryPass::class,
7878
];
7979

core-bundle/tests/DependencyInjection/Compiler/TwigPathsPassTest.php renamed to core-bundle/tests/DependencyInjection/Compiler/RewireTwigPathsPassTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
namespace Contao\CoreBundle\Tests\DependencyInjection\Compiler;
1414

15-
use Contao\CoreBundle\DependencyInjection\Compiler\TwigPathsPass;
15+
use Contao\CoreBundle\DependencyInjection\Compiler\RewireTwigPathsPass;
1616
use Contao\CoreBundle\Tests\TestCase;
1717
use Contao\CoreBundle\Twig\Loader\FailTolerantFilesystemLoader;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
1919
use Symfony\Component\DependencyInjection\Definition;
2020
use Twig\Loader\FilesystemLoader;
2121

22-
class TwigPathsPassTest extends TestCase
22+
class RewireTwigPathsPassTest extends TestCase
2323
{
2424
public function testRewiresAndAddsMethodCalls(): void
2525
{
@@ -38,7 +38,7 @@ public function testRewiresAndAddsMethodCalls(): void
3838
FailTolerantFilesystemLoader::class => $loader,
3939
]);
4040

41-
(new TwigPathsPass())->process($container);
41+
(new RewireTwigPathsPass())->process($container);
4242

4343
$this->assertFalse($baseLoader->hasMethodCall('addPath'));
4444
$this->assertTrue($baseLoader->hasMethodCall('foo'));

0 commit comments

Comments
 (0)