From a9dbbce68e88b1ac9c774a7e21bd6b48d4492cb7 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 14 May 2024 11:12:44 +0200 Subject: [PATCH] TASK: Allow PropertyName in `Node::getProperty` --- .../Classes/Projection/ContentGraph/Node.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index 70a79fc5fa8..ab33e6f0d97 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -23,6 +23,7 @@ use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeName; +use Neos\ContentRepository\Core\SharedModel\Node\PropertyName; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; @@ -169,13 +170,13 @@ public static function create(ContentRepositoryId $contentRepositoryId, Workspac /** * Returns the specified property, or null if it does not exist (or was set to null -> unset) * - * @param string $propertyName Name of the property + * @param PropertyName|string $propertyName Name of the property * @return mixed value of the property * @api */ - public function getProperty(string $propertyName): mixed + public function getProperty(PropertyName|string $propertyName): mixed { - return $this->properties->offsetGet($propertyName); + return $this->properties->offsetGet($propertyName instanceof PropertyName ? $propertyName->value : $propertyName); } /** @@ -183,13 +184,13 @@ public function getProperty(string $propertyName): mixed * * That means that {@see self::getProperty()} will not be null, except for the rare case the property deserializing returns null. * - * @param string $propertyName Name of the property + * @param PropertyName|string $propertyName Name of the property * @return boolean * @api */ - public function hasProperty(string $propertyName): bool + public function hasProperty(PropertyName|string $propertyName): bool { - return $this->properties->offsetExists($propertyName); + return $this->properties->offsetExists($propertyName instanceof PropertyName ? $propertyName->value : $propertyName); } /**