]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/BreadcrumbsViewComposer.php
ZIP Imports: Added API examples, finished testing
[bookstack] / app / Entities / BreadcrumbsViewComposer.php
index e46d54ec26fe1a53ec1902165fdae93a115b571c..c9269c7c66af95029029f4e600901692d5d8e07c 100644 (file)
@@ -1,31 +1,28 @@
-<?php namespace BookStack\Entities;
+<?php
 
+namespace BookStack\Entities;
+
+use BookStack\Entities\Models\Book;
+use BookStack\Entities\Tools\ShelfContext;
 use Illuminate\View\View;
 
 class BreadcrumbsViewComposer
 {
-
-    protected $entityContextManager;
-
-    /**
-     * BreadcrumbsViewComposer constructor.
-     * @param EntityContextManager $entityContextManager
-     */
-    public function __construct(EntityContextManager $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);