| @@ 150-158 (lines=9) @@ | ||
| 147 | $parents = $this->getParents()->all(); |
|
| 148 | $ids = array_flip($this->getParentsIds()); |
|
| 149 | $primaryKey = $this->getPrimaryKey(); |
|
| 150 | usort($parents, function($a, $b) use ($ids, $primaryKey) { |
|
| 151 | $aIdx = $ids[$a->$primaryKey]; |
|
| 152 | $bIdx = $ids[$b->$primaryKey]; |
|
| 153 | if ($aIdx == $bIdx) { |
|
| 154 | return 0; |
|
| 155 | } else { |
|
| 156 | return $aIdx > $bIdx ? -1 : 1; |
|
| 157 | } |
|
| 158 | }); |
|
| 159 | return $this->_parentsOrdered = $parents; |
|
| 160 | } |
|
| 161 | ||
| @@ 212-220 (lines=9) @@ | ||
| 209 | $descendants = $this->owner->descendants; |
|
| 210 | $ids = array_flip($this->getDescendantsIds(null, true)); |
|
| 211 | $primaryKey = $this->getPrimaryKey(); |
|
| 212 | usort($descendants, function($a, $b) use ($ids, $primaryKey) { |
|
| 213 | $aIdx = $ids[$a->$primaryKey]; |
|
| 214 | $bIdx = $ids[$b->$primaryKey]; |
|
| 215 | if ($aIdx == $bIdx) { |
|
| 216 | return 0; |
|
| 217 | } else { |
|
| 218 | return $aIdx > $bIdx ? -1 : 1; |
|
| 219 | } |
|
| 220 | }); |
|
| 221 | return $descendants; |
|
| 222 | } |
|
| 223 | ||