X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b12ae6d11b18acee1107b8182e7e666be05e3337..refs/pull/3406/head:/app/Entities/BreadcrumbsViewComposer.php diff --git a/app/Entities/BreadcrumbsViewComposer.php b/app/Entities/BreadcrumbsViewComposer.php index 7745d9aee..797162dfb 100644 --- a/app/Entities/BreadcrumbsViewComposer.php +++ b/app/Entities/BreadcrumbsViewComposer.php @@ -1,34 +1,40 @@ -entityContextManager = $entityContextManager; } /** * Modify data when the view is composed. + * * @param View $view */ 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 +}