Skip to content

Commit

Permalink
Merge pull request #10 from punktDe/feature/multiple-sorting-instruct…
Browse files Browse the repository at this point in the history
…ions-per-node-type

FEATURE: Allow multiple sorting instructions per node type
  • Loading branch information
daniellienert authored Mar 25, 2020
2 parents 0226c5a + 23d83ec commit dd1c5f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Classes/NodeSignalInterceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ public function nodeAdded(NodeInterface $node): void
return;
}

$this->createArchivist()->organizeNode($node, $this->sortingInstructions[$node->getNodeType()->getName()]);
$sortingInstructions = $this->sortingInstructions[$node->getNodeType()->getName()];

if (array_key_exists('hierarchyRoot', $sortingInstructions)) {
$sortingInstructions = [$sortingInstructions];
}

foreach ($sortingInstructions as $sortingInstruction) {
$this->createArchivist()->organizeNode($node, $sortingInstruction);
}
}

/**
Expand All @@ -61,9 +69,7 @@ public function nodeUpdated(NodeInterface $node): void
return;
}

if (array_key_exists($node->getNodeType()->getName(), $this->sortingInstructions ?? [])) {
$this->createArchivist()->organizeNode($node, $this->sortingInstructions[$node->getNodeType()->getName()]);
}
$this->nodeAdded($node);
}

/**
Expand Down

0 comments on commit dd1c5f8

Please sign in to comment.