public function normalize()
 {
     $serialManager = new SerialManager($this->items);
     $serialManager->normalize();
     $reorder = [];
     for ($i = 1; $i <= count($this->items); $i++) {
         $reorder[] = $serialManager->locate($i);
     }
     if (count($reorder) !== count($this->items)) {
         throw new \Exception('SerialManager did something completely wrong.');
     }
     $this->items = $reorder;
     foreach ($this->items as $subItem) {
         if ($subItem->sub()->hasChild()) {
             $subItem->sub()->normalize();
         }
     }
 }
示例#2
0
 private function normalizeTree(int $parentId = null)
 {
     $themes = $this->getThemesByParentId($parentId);
     $serialManager = new SerialManager($themes);
     $serialManager->normalize();
     return $themes;
 }