Skip to content

Commit

Permalink
Merge pull request #178 from neos/nodeTypeFallbackHandling
Browse files Browse the repository at this point in the history
Adjust to changed CR NodeType fallback handling
  • Loading branch information
ahaeslich authored Oct 8, 2023
2 parents 7a37864 + 4659736 commit c51796d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 37 deletions.
13 changes: 4 additions & 9 deletions Classes/Fusion/Helper/ImageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@

class ImageHelper implements ProtectedContextAwareInterface
{
/**
* @Flow\Inject
* @var ThumbnailService
*/
protected $thumbnailService;
#[Flow\Inject]
protected ThumbnailService $thumbnailService;

/**
* @param AssetInterface $asset
Expand Down Expand Up @@ -54,8 +51,7 @@ public function createThumbnail(
$async = false,
$quality = null,
$format = null
)
{
): ?ImageInterface {
if (!empty($preset)) {
$thumbnailConfiguration = $this->thumbnailService->getThumbnailConfigurationForPreset($preset);
} else {
Expand All @@ -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;
}
Expand Down
45 changes: 17 additions & 28 deletions Classes/Fusion/XmlSitemapUrlsImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,35 @@
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)]
use NodeTypeWithFallbackProvider;

#[Flow\Inject]
protected ContentRepositoryRegistry $contentRepositoryRegistry;

/**
* @var PersistenceManager
*/
#[Flow\Inject(lazy: true)]
protected $persistenceManager;
protected PersistenceManager $persistenceManager;

/**
* @var array<string, array<int, string>>
*/
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) {
Expand All @@ -74,9 +62,6 @@ public function getIncludeImageUrls(): bool
return $this->includeImageUrls;
}

/**
* @return bool
*/
public function getRenderHiddenInIndex(): bool
{
if ($this->renderHiddenInIndex === null) {
Expand All @@ -102,6 +87,7 @@ public function getStartingPoint(): Node
* Evaluate this Fusion object and return the result
*
* @return array
* @throws PropertyNotAccessibleException
*/
public function evaluate(): array
{
Expand Down Expand Up @@ -151,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;
Expand Down Expand Up @@ -205,7 +194,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))) {
Expand All @@ -230,7 +219,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
&& (
Expand Down

0 comments on commit c51796d

Please sign in to comment.