Skip to content
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
37 changes: 13 additions & 24 deletions src/Tree/Entity/Repository/NestedTreeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -879,12 +879,10 @@ public function verify(/* array $options = [] */) // @phpstan-ignore-line
$meta = $this->getClassMetadata();
$config = $this->listener->getConfiguration($this->getEntityManager(), $meta->getName());
if (isset($config['root'])) {
$trees = $this->getRootNodes();
$trees = null !== $options['treeRootNode']
? [$options['treeRootNode']] // if a root node is specified, verify only it
: $this->getRootNodes();
foreach ($trees as $tree) {
// if a root node is specified, verify only it
if (null !== $options['treeRootNode'] && $options['treeRootNode'] !== $tree) {
continue;
}
$this->verifyTree($errors, $tree);
}
} else {
Expand Down Expand Up @@ -1034,29 +1032,20 @@ public function recover(/* array $options = [] */) // @phpstan-ignore-line

// if it's a forest
if (isset($config['root'])) {
foreach ($this->getRootNodes($options['sortByField'], $options['sortDirection']) as $root) {
// if a root node is specified, recover only it
if (null !== $options['treeRootNode'] && $options['treeRootNode'] !== $root) {
continue;
}

$count = 1; // reset on every root node
$lvl = $config['level_base'] ?? 0;
$doRecover($root, $count, $lvl);

if ($options['flush']) {
$em->flush();
}
}
$roots = null !== $options['treeRootNode']
? [$options['treeRootNode']]
: $this->getRootNodes($options['sortByField'], $options['sortDirection']);
} else {
$roots = $this->getChildren(null, true, $options['sortByField'], $options['sortDirection']);
}

foreach ($roots as $root) {
$count = 1;
$lvl = $config['level_base'] ?? 0;
foreach ($this->getChildren(null, true, $options['sortByField'], $options['sortDirection']) as $root) {
$doRecover($root, $count, $lvl);
$doRecover($root, $count, $lvl);

Comment on lines +1042 to 1046
if ($options['flush']) {
$em->flush();
}
if ($options['flush']) {
$em->flush();
}
}
}
Expand Down