Skip to content

Commit

Permalink
TASK: Allow PropertyName in Node::getProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed May 14, 2024
1 parent 96ce9e9 commit a9dbbce
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 a9dbbce

Please sign in to comment.