X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c429cf78187e80deb63982a282a1c6889f30291a..refs/pull/5405/head:/app/Entities/BreadcrumbsViewComposer.php diff --git a/app/Entities/BreadcrumbsViewComposer.php b/app/Entities/BreadcrumbsViewComposer.php index 797162dfb..c9269c7c6 100644 --- a/app/Entities/BreadcrumbsViewComposer.php +++ b/app/Entities/BreadcrumbsViewComposer.php @@ -8,29 +8,21 @@ use Illuminate\View\View; class BreadcrumbsViewComposer { - protected $entityContextManager; - - /** - * BreadcrumbsViewComposer constructor. - * - * @param ShelfContext $entityContextManager - */ - public function __construct(ShelfContext $entityContextManager) - { - $this->entityContextManager = $entityContextManager; + public function __construct( + protected ShelfContext $shelfContext + ) { } /** * Modify data when the view is composed. - * - * @param View $view */ - public function compose(View $view) + public function compose(View $view): void { $crumbs = $view->getData()['crumbs']; $firstCrumb = $crumbs[0] ?? null; + if ($firstCrumb instanceof Book) { - $shelf = $this->entityContextManager->getContextualShelfForBook($firstCrumb); + $shelf = $this->shelfContext->getContextualShelfForBook($firstCrumb); if ($shelf) { array_unshift($crumbs, $shelf); $view->with('crumbs', $crumbs);