Skip to content

Commit

Permalink
Merge pull request #5052 from mhsdesign/task/allowPropertyNameInNodeG…
Browse files Browse the repository at this point in the history
…etProperty

TASK: Allow PropertyName in `Node::getProperty`
  • Loading branch information
bwaidelich committed May 17, 2024
2 parents b3d32bf + a9dbbce commit d39c363
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -169,27 +170,27 @@ 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);
}

/**
* If this node has a property with the given name. It does not check if the property exists in the current NodeType schema.
*
* 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);
}

/**
Expand Down

0 comments on commit d39c363

Please sign in to comment.