Skip to content

Commit cc5d72c

Browse files
committed
Do not try to generate fragments for generated fragments
1 parent 4d0bdba commit cc5d72c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core-bundle/src/DependencyInjection/Compiler/RegisterFragmentsPass.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ protected function registerFragments(ContainerBuilder $container, string $tag):
8383
$command = $container->hasDefinition('contao.command.debug_fragments') ? $container->findDefinition('contao.command.debug_fragments') : null;
8484

8585
foreach ($this->findAndSortTaggedServices($tag, $container) as $reference) {
86+
// If a controller has multiple methods for different fragment type (e.g. a content element
87+
// and a front end module), the first RegisterFragmentsPass creates a child definition that
88+
// inherits all tags from the original. On the next run, the RegisterFragmentsPass would
89+
// pick up the child definition and try to create duplicate fragments.
90+
if (0 === strpos((string) $reference, 'contao.fragment._')) {
91+
continue;
92+
}
93+
8694
$definition = $container->findDefinition($reference);
8795

8896
$tags = $definition->getTag($tag);

0 commit comments

Comments
 (0)