|
@@ -271,7 +271,17 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
}
|
|
}
|
|
if (!$sortByField) {
|
|
if (!$sortByField) {
|
|
$qb->orderBy('node.' . $config['left'], 'ASC');
|
|
$qb->orderBy('node.' . $config['left'], 'ASC');
|
|
- } else {
|
|
|
|
|
|
+ }
|
|
|
|
+ elseif (is_array($sortByField)) {
|
|
|
|
+ $fields = '';
|
|
|
|
+ foreach ($sortByField as $field)
|
|
|
|
+ {
|
|
|
|
+ $fields .= 'node.'.$field.',';
|
|
|
|
+ }
|
|
|
|
+ $fields=rtrim($fields,',');
|
|
|
|
+ $qb->orderBy($fields,$direction);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
if ($meta->hasField($sortByField) && in_array(strtolower($direction), array('asc', 'desc'))) {
|
|
if ($meta->hasField($sortByField) && in_array(strtolower($direction), array('asc', 'desc'))) {
|
|
$qb->orderBy('node.' . $sortByField, $direction);
|
|
$qb->orderBy('node.' . $sortByField, $direction);
|
|
} else {
|
|
} else {
|
|
@@ -286,7 +296,7 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
*
|
|
*
|
|
* @param object $node - if null, all tree nodes will be taken
|
|
* @param object $node - if null, all tree nodes will be taken
|
|
* @param boolean $direct - true to take only direct children
|
|
* @param boolean $direct - true to take only direct children
|
|
- * @param string $sortByField - field name to sort by
|
|
|
|
|
|
+ * @param string|array $sortByField - field names to sort by
|
|
* @param string $direction - sort direction : "ASC" or "DESC"
|
|
* @param string $direction - sort direction : "ASC" or "DESC"
|
|
* @return Doctrine\ORM\Query
|
|
* @return Doctrine\ORM\Query
|
|
*/
|
|
*/
|
|
@@ -799,11 +809,11 @@ class NestedTreeRepository extends AbstractTreeRepository
|
|
}
|
|
}
|
|
|
|
|
|
// Gets the array of $node results.
|
|
// Gets the array of $node results.
|
|
- // It must be order by 'root' field
|
|
|
|
|
|
+ // It must be order by 'root' and 'left' field
|
|
$nodes = self::childrenQuery(
|
|
$nodes = self::childrenQuery(
|
|
$node,
|
|
$node,
|
|
$direct,
|
|
$direct,
|
|
- isset($config['root']) ? $config['root'] : $config['left'],
|
|
|
|
|
|
+ array($config['root'],$config['left']),
|
|
'ASC'
|
|
'ASC'
|
|
)->getArrayResult();
|
|
)->getArrayResult();
|
|
|
|
|