]> 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 97ddbc2dc86764ed930c82d3c549f47b35c83fe1..e46d54ec26fe1a53ec1902165fdae93a115b571c 100644 (file)
@@ -23,8 +23,9 @@ 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);