|
@@ -707,10 +707,10 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Reorders the sibling nodes and child nodes by given $node,
|
|
|
|
|
|
+ * Reorders $node's sibling nodes and child nodes,
|
|
* according to the $sortByField and $direction specified
|
|
* according to the $sortByField and $direction specified
|
|
*
|
|
*
|
|
- * @param object $node - from which node to start reordering the tree
|
|
|
|
|
|
+ * @param object|null $node - node from which to start reordering the tree; null will reorder everything
|
|
* @param string $sortByField - field name to sort by
|
|
* @param string $sortByField - field name to sort by
|
|
* @param string $direction - sort direction : "ASC" or "DESC"
|
|
* @param string $direction - sort direction : "ASC" or "DESC"
|
|
* @param boolean $verify - true to verify tree first
|
|
* @param boolean $verify - true to verify tree first
|
|
@@ -719,7 +719,7 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
public function reorder($node, $sortByField = null, $direction = 'ASC', $verify = true)
|
|
public function reorder($node, $sortByField = null, $direction = 'ASC', $verify = true)
|
|
{
|
|
{
|
|
$meta = $this->getClassMetadata();
|
|
$meta = $this->getClassMetadata();
|
|
- if ($node instanceof $meta->name) {
|
|
|
|
|
|
+ if ($node instanceof $meta->name || $node==null) {
|
|
$config = $this->listener->getConfiguration($this->_em, $meta->name);
|
|
$config = $this->listener->getConfiguration($this->_em, $meta->name);
|
|
if ($verify && is_array($this->verify())) {
|
|
if ($verify && is_array($this->verify())) {
|
|
return false;
|
|
return false;
|
|
@@ -740,6 +740,19 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Reorders all nodes in the tree according to the $sortByField and $direction specified.
|
|
|
|
+ *
|
|
|
|
+ * @param string $sortByField - field name to sort by
|
|
|
|
+ * @param string $direction - sort direction : "ASC" or "DESC"
|
|
|
|
+ * @param boolean $verify - true to verify tree first
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function reorderAll($sortByField = null, $direction = 'ASC', $verify = true)
|
|
|
|
+ {
|
|
|
|
+ $this->reorder(null, $sortByField, $direction, $verify);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Verifies that current tree is valid.
|
|
* Verifies that current tree is valid.
|
|
* If any error is detected it will return an array
|
|
* If any error is detected it will return an array
|