| Total Complexity | 9 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Coverage | 96% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class BreadcrumbsRenderer |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * The breadcrumb trail. |
||
| 16 | * |
||
| 17 | * @var Breadcrumbs |
||
| 18 | */ |
||
| 19 | protected $breadcrumbs; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var View |
||
| 23 | */ |
||
| 24 | protected $view = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * BreadcrumbsRenderer constructor. |
||
| 28 | * @param Breadcrumbs $breadcrumbs |
||
| 29 | */ |
||
| 30 | 1 | public function __construct(Breadcrumbs $breadcrumbs) |
|
| 31 | { |
||
| 32 | 1 | $this->breadcrumbs = $breadcrumbs; |
|
| 33 | 1 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * @return string |
||
| 37 | */ |
||
| 38 | 1 | public function render() |
|
| 39 | { |
||
| 40 | 1 | $path = $this->detectViewPath(); |
|
| 41 | 1 | return $this->renderView($path); |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param $path |
||
| 46 | * @return string |
||
| 47 | */ |
||
| 48 | 1 | protected function renderView($path) |
|
| 49 | { |
||
| 50 | 1 | $view = $this->getView(); |
|
| 51 | 1 | $view->set('breadcrumbs', $this->breadcrumbs); |
|
| 52 | 1 | return $view->load($path, ['breadcrumbs' => $this->breadcrumbs], true); |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return View |
||
| 57 | */ |
||
| 58 | 1 | public function getView(): View |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @param View $view |
||
| 68 | */ |
||
| 69 | 1 | public function setView(View $view): void |
|
| 70 | { |
||
| 71 | 1 | $view->addPath(NavigationHelper::view('/breadcrumbs'), 'breadcrumbs'); |
|
| 72 | 1 | $this->view = $view; |
|
| 73 | 1 | } |
|
| 74 | |||
| 75 | 1 | protected function initView() |
|
| 76 | { |
||
| 77 | 1 | $this->setView(new View()); |
|
| 78 | 1 | } |
|
| 79 | |||
| 80 | /** |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | 1 | protected function detectViewPath() |
|
| 89 | } |
||
| 90 | |||
| 91 | } |