| @@ 151-159 (lines=9) @@ | ||
| 148 | $parents = $this->getParents($depth)->all(); |
|
| 149 | $ids = array_flip($this->getParentsIds()); |
|
| 150 | $primaryKey = $this->getPrimaryKey(); |
|
| 151 | usort($parents, function($a, $b) use ($ids, $primaryKey) { |
|
| 152 | $aIdx = $ids[$a->$primaryKey]; |
|
| 153 | $bIdx = $ids[$b->$primaryKey]; |
|
| 154 | if ($aIdx == $bIdx) { |
|
| 155 | return 0; |
|
| 156 | } else { |
|
| 157 | return $aIdx > $bIdx ? -1 : 1; |
|
| 158 | } |
|
| 159 | }); |
|
| 160 | if ($depth !== null) { |
|
| 161 | $this->_parentsOrdered = $parents; |
|
| 162 | } |
|
| @@ 221-229 (lines=9) @@ | ||
| 218 | } |
|
| 219 | $ids = array_flip($this->getDescendantsIds($depth, true)); |
|
| 220 | $primaryKey = $this->getPrimaryKey(); |
|
| 221 | usort($descendants, function($a, $b) use ($ids, $primaryKey) { |
|
| 222 | $aIdx = $ids[$a->$primaryKey]; |
|
| 223 | $bIdx = $ids[$b->$primaryKey]; |
|
| 224 | if ($aIdx == $bIdx) { |
|
| 225 | return 0; |
|
| 226 | } else { |
|
| 227 | return $aIdx > $bIdx ? 1 : -1; |
|
| 228 | } |
|
| 229 | }); |
|
| 230 | return $descendants; |
|
| 231 | } |
|
| 232 | ||