]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/BreadcrumbsViewComposer.php
Show bookshelves that a book belongs to on a book view
[bookstack] / app / Entities / BreadcrumbsViewComposer.php
index 7745d9aee5418549143237a550a78f0599eb8224..e46d54ec26fe1a53ec1902165fdae93a115b571c 100644 (file)
@@ -23,12 +23,13 @@ class BreadcrumbsViewComposer
     public function compose(View $view)
     {
         $crumbs = $view->getData()['crumbs'];
-        if (array_first($crumbs) instanceof Book) {
-            $shelf = $this->entityContextManager->getContextualShelfForBook(array_first($crumbs));
+        $firstCrumb = $crumbs[0] ?? null;
+        if ($firstCrumb instanceof Book) {
+            $shelf = $this->entityContextManager->getContextualShelfForBook($firstCrumb);
             if ($shelf) {
                 array_unshift($crumbs, $shelf);
                 $view->with('crumbs', $crumbs);
             }
         }
     }
-}
\ No newline at end of file
+}