mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 04:05:57 +00:00
![Dan Brown](/assets/img/avatar_default.png)
- Updated breadcrumb dropdown switchers and back-end sibling code to handle new breadcrumbs. - Added breadcrumb view composer and EntityContext system to mangage tracking if in the context of a bookshelf.
34 lines
885 B
PHP
34 lines
885 B
PHP
<?php namespace BookStack\Entities;
|
|
|
|
use Illuminate\View\View;
|
|
|
|
class BreadcrumbsViewComposer
|
|
{
|
|
|
|
protected $entityContextManager;
|
|
|
|
/**
|
|
* BreadcrumbsViewComposer constructor.
|
|
* @param EntityContextManager $entityContextManager
|
|
*/
|
|
public function __construct(EntityContextManager $entityContextManager)
|
|
{
|
|
$this->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));
|
|
if ($shelf) {
|
|
array_unshift($crumbs, $shelf);
|
|
$view->with('crumbs', $crumbs);
|
|
}
|
|
}
|
|
}
|
|
} |