Skip to content

Commit 5322b46

Browse files
Merge pull request #552 from CPS-IT/fix/view-factory
[BUGFIX] Use `FluidViewFactory` for `XmlSitemapRenderer`
2 parents 5807ecb + afdc5b2 commit 5322b46

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

Configuration/Services.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\DependencyInjection;
2323
use TYPO3\CMS\Fluid;
2424
use TYPO3\CMS\Frontend;
25+
use TYPO3\CMS\Seo;
2526

2627
return static function (
2728
DependencyInjection\ContainerBuilder $container,
@@ -52,11 +53,19 @@ static function (DependencyInjection\ChildDefinition $definition, Attribute\AsHe
5253
},
5354
);
5455

55-
// Make sure the FLUIDTEMPLATE content object always receives an instance of FluidViewFactory,
56-
// because it fails hard if any other view than FluidViewAdapter is resolved, which cannot be
57-
// assured when using our custom HandlebarsViewFactory, as we don't know the exact context.
58-
$configurator->services()
59-
->get(Frontend\ContentObject\FluidTemplateContentObject::class)
60-
->arg('$viewFactory', new DependencyInjection\Reference(Fluid\View\FluidViewFactory::class))
61-
;
56+
// Make sure various services always receive an instance of FluidViewFactory, because they fail
57+
// hard if any other view than FluidViewAdapter is resolved, which cannot be assured when using
58+
// our custom HandlebarsViewFactory, as we don't know the exact context.
59+
$services = $configurator->services();
60+
$fluidViewFactoryReference = new DependencyInjection\Reference(Fluid\View\FluidViewFactory::class);
61+
$servicesRequestingFluidViewFactory = [
62+
Frontend\ContentObject\FluidTemplateContentObject::class => '$viewFactory',
63+
Seo\XmlSitemap\XmlSitemapRenderer::class => '$viewFactory',
64+
];
65+
66+
foreach ($servicesRequestingFluidViewFactory as $className => $argumentName) {
67+
if (class_exists($className)) {
68+
$services->get($className)->arg($argumentName, $fluidViewFactoryReference);
69+
}
70+
}
6271
};

phpstan-baseline.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ parameters:
5454
count: 1
5555
path: Classes/View/HandlebarsViewFactory.php
5656

57+
-
58+
rawMessage: Class TYPO3\CMS\Seo\XmlSitemap\XmlSitemapRenderer not found.
59+
identifier: class.notFound
60+
count: 1
61+
path: Configuration/Services.php
62+
5763
-
5864
rawMessage: Attribute class PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations does not exist.
5965
identifier: attribute.notFound

0 commit comments

Comments
 (0)