1 <?php namespace BookStack\Entities;
3 use Illuminate\View\View;
5 class BreadcrumbsViewComposer
8 protected $entityContextManager;
11 * BreadcrumbsViewComposer constructor.
12 * @param EntityContextManager $entityContextManager
14 public function __construct(EntityContextManager $entityContextManager)
16 $this->entityContextManager = $entityContextManager;
20 * Modify data when the view is composed.
23 public function compose(View $view)
25 $crumbs = $view->getData()['crumbs'];
26 if (array_first($crumbs) instanceof Book) {
27 $shelf = $this->entityContextManager->getContextualShelfForBook(array_first($crumbs));
29 array_unshift($crumbs, $shelf);
30 $view->with('crumbs', $crumbs);