Skip to content

Commit

Permalink
fix(Node): Always set node TTL against its node-type
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed May 22, 2024
1 parent 353d4f4 commit a772d06
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/RoadizCoreBundle/src/Node/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public function create(
$node->setNodeType($type);
}

if ($type instanceof NodeType) {
$node->setTtl($type->getDefaultTtl());
if ($node->getNodeType() instanceof NodeType) {
$node->setTtl($node->getNodeType()->getDefaultTtl());
}

if (null !== $parent) {
$node->setParent($parent);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Rozier/src/Controllers/Nodes/NodesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public function addAction(Request $request, int $nodeTypeId, ?int $translationId

$node = new Node();
$node->setNodeType($type);
$node->setTtl($type->getDefaultTtl());

$chroot = $this->nodeChrootResolver->getChroot($this->getUser());
if (null !== $chroot) {
Expand Down
4 changes: 1 addition & 3 deletions lib/Rozier/src/Traits/NodesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ abstract protected function getNodeFactory(): NodeFactory;
* @param NodeTypeInterface|null $type
*
* @return Node
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
*/
protected function createNode(
$title,
string $title,
TranslationInterface $translation,
Node $node = null,
NodeTypeInterface $type = null
Expand Down

0 comments on commit a772d06

Please sign in to comment.