From 873acb707e6a5fe1b3cc92a8180125d4f97d6f8f Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Fri, 1 Sep 2023 17:25:58 +0200 Subject: [PATCH 1/3] Adjust to changed CR NodeType fallback handling --- Classes/Fusion/XmlSitemapUrlsImplementation.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Classes/Fusion/XmlSitemapUrlsImplementation.php b/Classes/Fusion/XmlSitemapUrlsImplementation.php index 57170cf..953de02 100644 --- a/Classes/Fusion/XmlSitemapUrlsImplementation.php +++ b/Classes/Fusion/XmlSitemapUrlsImplementation.php @@ -19,17 +19,16 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; -use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\Doctrine\PersistenceManager; use Neos\Fusion\FusionObjects\AbstractFusionObject; use Neos\Media\Domain\Model\ImageInterface; +use Neos\Neos\Utility\NodeTypeWithFallbackProvider; use Neos\Utility\Exception\PropertyNotAccessibleException; class XmlSitemapUrlsImplementation extends AbstractFusionObject { - #[Flow\Inject(lazy: false)] - protected ContentRepositoryRegistry $contentRepositoryRegistry; + use NodeTypeWithFallbackProvider; /** * @var PersistenceManager @@ -205,7 +204,7 @@ protected function collectItems(array &$items, Subtree $subtree): void protected function resolveImages(Subtree $subtree, array &$item): void { $node = $subtree->node; - $assetPropertiesForNodeType = $this->getAssetPropertiesForNodeType($node->nodeType); + $assetPropertiesForNodeType = $this->getAssetPropertiesForNodeType($this->getNodeType($node)); foreach ($assetPropertiesForNodeType as $propertyName) { if (is_array($node->getProperty($propertyName)) && !empty($node->getProperty($propertyName))) { @@ -230,7 +229,7 @@ protected function resolveImages(Subtree $subtree, array &$item): void */ protected function isDocumentNodeToBeIndexed(Node $node): bool { - return !$node->nodeType->isOfType('Neos.Seo:NoindexMixin') + return !$this->getNodeType($node)->isOfType('Neos.Seo:NoindexMixin') && ($this->getRenderHiddenInIndex() || $node->getProperty('hiddenInIndex') !== true) && $node->getProperty('metaRobotsNoindex') !== true && ( From 162d370ff5b0bdda53ba07b8da04455e2362f90c Mon Sep 17 00:00:00 2001 From: Bernhard Schmitt Date: Wed, 20 Sep 2023 23:25:33 +0200 Subject: [PATCH 2/3] Explicitly require CR registry provider --- Classes/Fusion/XmlSitemapUrlsImplementation.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Classes/Fusion/XmlSitemapUrlsImplementation.php b/Classes/Fusion/XmlSitemapUrlsImplementation.php index 953de02..a836233 100644 --- a/Classes/Fusion/XmlSitemapUrlsImplementation.php +++ b/Classes/Fusion/XmlSitemapUrlsImplementation.php @@ -19,6 +19,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; +use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\Doctrine\PersistenceManager; use Neos\Fusion\FusionObjects\AbstractFusionObject; @@ -28,6 +29,7 @@ class XmlSitemapUrlsImplementation extends AbstractFusionObject { + use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; /** From 46597362179c89b36f53e3cc43c2a74cdbb98c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anke=20H=C3=A4slich?= Date: Sun, 8 Oct 2023 13:43:12 +0200 Subject: [PATCH 3/3] Adjust to removal of `ContentRepositoryRegistryProvider` Relates: neos/neos-development-collection#4466 --- Classes/Fusion/Helper/ImageHelper.php | 13 ++---- .../Fusion/XmlSitemapUrlsImplementation.php | 42 +++++++------------ 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/Classes/Fusion/Helper/ImageHelper.php b/Classes/Fusion/Helper/ImageHelper.php index 51ebe3c..179d0fd 100644 --- a/Classes/Fusion/Helper/ImageHelper.php +++ b/Classes/Fusion/Helper/ImageHelper.php @@ -21,11 +21,8 @@ class ImageHelper implements ProtectedContextAwareInterface { - /** - * @Flow\Inject - * @var ThumbnailService - */ - protected $thumbnailService; + #[Flow\Inject] + protected ThumbnailService $thumbnailService; /** * @param AssetInterface $asset @@ -54,8 +51,7 @@ public function createThumbnail( $async = false, $quality = null, $format = null - ) - { + ): ?ImageInterface { if (!empty($preset)) { $thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset); } else { @@ -82,9 +78,8 @@ public function createThumbnail( * All methods are considered safe * * @param string $methodName - * @return boolean */ - public function allowsCallOfMethod($methodName) + public function allowsCallOfMethod($methodName): bool { return true; } diff --git a/Classes/Fusion/XmlSitemapUrlsImplementation.php b/Classes/Fusion/XmlSitemapUrlsImplementation.php index a836233..8777a07 100644 --- a/Classes/Fusion/XmlSitemapUrlsImplementation.php +++ b/Classes/Fusion/XmlSitemapUrlsImplementation.php @@ -19,7 +19,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\NodeTypeConstraints; use Neos\ContentRepository\Core\Projection\ContentGraph\Subtree; -use Neos\ContentRepositoryRegistry\Utility\ContentRepositoryRegistryProvider; +use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Annotations as Flow; use Neos\Flow\Persistence\Doctrine\PersistenceManager; use Neos\Fusion\FusionObjects\AbstractFusionObject; @@ -29,43 +29,30 @@ class XmlSitemapUrlsImplementation extends AbstractFusionObject { - use ContentRepositoryRegistryProvider; use NodeTypeWithFallbackProvider; - /** - * @var PersistenceManager - */ + #[Flow\Inject] + protected ContentRepositoryRegistry $contentRepositoryRegistry; + #[Flow\Inject(lazy: true)] - protected $persistenceManager; + protected PersistenceManager $persistenceManager; /** * @var array> */ - protected $assetPropertiesByNodeType = []; + protected array $assetPropertiesByNodeType = []; - /** - * @var bool - */ - protected $renderHiddenInIndex; + protected ?bool $renderHiddenInIndex = null; - /** - * @var bool - */ - protected $includeImageUrls; + protected ?bool $includeImageUrls = null; - /** - * @var Node - */ - protected $startingPoint; + protected ?Node $startingPoint = null; /** - * @var array + * @var array|null */ - protected $items; + protected ?array $items = null; - /** - * @return bool - */ public function getIncludeImageUrls(): bool { if ($this->includeImageUrls === null) { @@ -75,9 +62,6 @@ public function getIncludeImageUrls(): bool return $this->includeImageUrls; } - /** - * @return bool - */ public function getRenderHiddenInIndex(): bool { if ($this->renderHiddenInIndex === null) { @@ -103,6 +87,7 @@ public function getStartingPoint(): Node * Evaluate this Fusion object and return the result * * @return array + * @throws PropertyNotAccessibleException */ public function evaluate(): array { @@ -152,6 +137,9 @@ private function getAssetPropertiesForNodeType(NodeType $nodeType): array return $this->assetPropertiesByNodeType[$nodeType->name->value]; } + /** + * @throws PropertyNotAccessibleException + */ protected function collectItems(array &$items, Subtree $subtree): void { $node = $subtree->node;