Skip to content

Commit

Permalink
BUGFIX: Use an auto-generated node name if none is given
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Apr 23, 2019
1 parent c4872e2 commit b6b949c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Classes/Service/HierarchyService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);

namespace PunktDe\Archivist\Service;

/*
Expand Down Expand Up @@ -96,7 +98,7 @@ public function buildHierarchy(array $hierarchyConfiguration, array $context, bo
*/
protected function buildHierarchyLevel(NodeInterface $parentNode, array $hierarchyLevelConfiguration, array $context, bool $publishHierarchy): NodeInterface
{
$hierarchyLevelNodeName = '';
$hierarchyLevelNodeName = null;
$this->evaluateHierarchyLevelConfiguration($hierarchyLevelConfiguration);

$hierarchyLevelNodeType = $this->nodeTypeManager->getNodeType($hierarchyLevelConfiguration['type']);
Expand All @@ -112,14 +114,17 @@ protected function buildHierarchyLevel(NodeInterface $parentNode, array $hierarc
$hierarchyLevelNodeTemplate = new NodeTemplate();
$hierarchyLevelNodeTemplate->setNodeType($hierarchyLevelNodeType);


if (isset($hierarchyLevelConfiguration['properties']['name'])) {
$hierarchyLevelNodeName = (string)$this->eelEvaluationService->evaluateIfValidEelExpression($hierarchyLevelConfiguration['properties']['name'], $context);
$hierarchyLevelNodeTemplate->setName(NodeUtility::renderValidNodeName($hierarchyLevelNodeName));
unset($hierarchyLevelConfiguration['properties']['name']);
}

if ($hierarchyLevelNodeName === '') {
return $parentNode;
if($hierarchyLevelNodeName !== '') {
$hierarchyLevelNodeTemplate->setName(NodeUtility::renderValidNodeName($hierarchyLevelNodeName));
} else {
$hierarchyLevelNodeName = null;
}

unset($hierarchyLevelConfiguration['properties']['name']);
}

if (isset($hierarchyLevelConfiguration['properties'])) {
Expand Down Expand Up @@ -223,6 +228,7 @@ protected function publishNodeAndChildContent(NodeInterface $node): void
}
}

$this->logger->log('Publishing node ' . $node->__toString(), LOG_DEBUG);
$this->publishingService->publishNode($node);
}
}

0 comments on commit b6b949c

Please sign in to comment.