X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7c8c4c2a0568b792f084379de73bdb83113a2e6b..refs/pull/270/head:/app/Repos/EntityRepo.php diff --git a/app/Repos/EntityRepo.php b/app/Repos/EntityRepo.php index 0515a4cd4..6eaf0169a 100644 --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@ -318,15 +318,15 @@ class EntityRepo */ public function getBookChildren(Book $book, $filterDrafts = false) { - $q = $this->permissionService->bookChildrenQuery($book->id, $filterDrafts); + $q = $this->permissionService->bookChildrenQuery($book->id, $filterDrafts)->get(); $entities = []; $parents = []; $tree = []; foreach ($q as $index => $rawEntity) { - if ($rawEntity->entity_type === 'Bookstack\\Page') { + if ($rawEntity->entity_type === 'BookStack\\Page') { $entities[$index] = $this->page->newFromBuilder($rawEntity); - } else if ($rawEntity->entity_type === 'Bookstack\\Chapter') { + } else if ($rawEntity->entity_type === 'BookStack\\Chapter') { $entities[$index] = $this->chapter->newFromBuilder($rawEntity); $key = $entities[$index]->entity_type . ':' . $entities[$index]->id; $parents[$key] = $entities[$index]; @@ -338,7 +338,7 @@ class EntityRepo foreach ($entities as $entity) { if ($entity->chapter_id === 0) continue; - $parentKey = 'Bookstack\\Chapter:' . $entity->chapter_id; + $parentKey = 'BookStack\\Chapter:' . $entity->chapter_id; $chapter = $parents[$parentKey]; $chapter->pages->push($entity); } @@ -836,18 +836,18 @@ class EntityRepo /** * Parse the headers on the page to get a navigation menu * @param Page $page - * @return Collection + * @return array */ public function getPageNav(Page $page) { - if ($page->html == '') return null; + if ($page->html == '') return []; libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc->loadHTML(mb_convert_encoding($page->html, 'HTML-ENTITIES', 'UTF-8')); $xPath = new DOMXPath($doc); $headers = $xPath->query("//h1|//h2|//h3|//h4|//h5|//h6"); - if (is_null($headers)) return null; + if (is_null($headers)) return []; $tree = collect([]); foreach ($headers as $header) { @@ -868,7 +868,7 @@ class EntityRepo return $header; }); } - return $tree; + return $tree->toArray(); } /**