Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use defaultValues from NodeTypes.yaml for hierarchy nodes #7

Open
wants to merge 1 commit into
base: 2.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Classes/Service/HierarchyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function buildHierarchy(array $hierarchyConfiguration, array $context, bo
* @return NodeInterface The created or found hierarchy node
* @throws ArchivistConfigurationException
* @throws NodeTypeNotFoundException
* @throws \Neos\ContentRepository\Exception\NodeExistsException
* @throws \Neos\Eel\Exception
*/
protected function buildHierarchyLevel(NodeInterface $parentNode, array $hierarchyLevelConfiguration, array $context, bool $publishHierarchy): NodeInterface
Expand Down Expand Up @@ -127,16 +128,16 @@ protected function buildHierarchyLevel(NodeInterface $parentNode, array $hierarc
unset($hierarchyLevelConfiguration['properties']['name']);
}

$hierarchyLevelNode = $parentNode->createNode($hierarchyLevelNodeTemplate->getName(), $hierarchyLevelNodeTemplate->getNodeType());

if (isset($hierarchyLevelConfiguration['properties'])) {
$this->applyProperties($hierarchyLevelNodeTemplate, $hierarchyLevelConfiguration['properties'], $context);
$this->applyProperties($hierarchyLevelNode, $hierarchyLevelConfiguration['properties'], $context);
}

if ($hierarchyLevelNodeType->isOfType('Neos.Neos:Document') && !isset($hierarchyLevelConfiguration['properties']['uriPathSegment'])) {
$hierarchyLevelNodeTemplate->setProperty('uriPathSegment', $hierarchyLevelNodeTemplate->getName());
$hierarchyLevelNode->setProperty('uriPathSegment', $hierarchyLevelNode->getName());
}

$hierarchyLevelNode = $parentNode->createNodeFromTemplate($hierarchyLevelNodeTemplate, $hierarchyLevelNodeName);

$this->logger->log(sprintf('Built hierarchy level on path %s with node type %s ', $hierarchyLevelNode->getPath(), $hierarchyLevelConfiguration['type']), LOG_DEBUG);

if (isset($hierarchyLevelConfiguration['sorting'])) {
Expand All @@ -155,12 +156,12 @@ protected function buildHierarchyLevel(NodeInterface $parentNode, array $hierarc
}

/**
* @param NodeTemplate $node
* @param NodeInterface $node
* @param array $properties
* @param array $context
* @throws \Neos\Eel\Exception
*/
protected function applyProperties(NodeTemplate $node, array $properties, array $context)
protected function applyProperties(NodeInterface $node, array $properties, array $context)
{
foreach ($properties as $propertyName => $propertyValue) {
$propertyValue = $this->eelEvaluationService->evaluateIfValidEelExpression($propertyValue, $context);
Expand Down