Skip to content

Commit

Permalink
TASK: Make use of requireNodeTypeToDeclareProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Nov 16, 2023
1 parent 5b9e092 commit 7c2574c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePointSet;
use Neos\ContentRepository\Core\DimensionSpace\Exception\DimensionSpacePointNotFound;
use Neos\ContentRepository\Core\NodeType\ConstraintCheck;
use Neos\ContentRepository\Core\SharedModel\Exception\PropertyCannotBeSet;
use Neos\ContentRepository\Core\SharedModel\Exception\RootNodeAggregateDoesNotExist;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamDoesNotExistYet;
use Neos\ContentRepository\Core\SharedModel\Exception\DimensionSpacePointIsNotYetOccupied;
Expand Down Expand Up @@ -191,7 +192,11 @@ protected function requireTetheredDescendantNodeTypesToNotBeOfTypeRoot(NodeType
protected function requireNodeTypeToDeclareProperty(NodeTypeName $nodeTypeName, PropertyName $propertyName): void
{
$nodeType = $this->getNodeTypeManager()->getNodeType($nodeTypeName->value);
if (!isset($nodeType->getProperties()[$propertyName->value])) {
if (!$nodeType->hasProperty($propertyName->value)) {
throw PropertyCannotBeSet::becauseTheNodeTypeDoesNotDeclareIt(
$propertyName,
$nodeTypeName
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ private function validateProperties(?PropertyValuesToWrite $propertyValues, Node

$nodeType = $this->nodeTypeManager->getNodeType($nodeTypeName->value);
foreach ($propertyValues->values as $propertyName => $propertyValue) {
if (!isset($nodeType->getProperties()[$propertyName])) {
throw PropertyCannotBeSet::becauseTheNodeTypeDoesNotDeclareIt(
PropertyName::fromString($propertyName),
$nodeTypeName
);
}
$this->requireNodeTypeToDeclareProperty($nodeTypeName, PropertyName::fromString($propertyName));
$propertyType = PropertyType::fromNodeTypeDeclaration(
$nodeType->getPropertyType($propertyName),
PropertyName::fromString($propertyName),
Expand Down

0 comments on commit 7c2574c

Please sign in to comment.