|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SleepingOwl\Admin\Templates; |
|
4
|
|
|
|
|
5
|
|
|
use DaveJamesMiller\Breadcrumbs\Manager as BreadcrumbsManager; |
|
6
|
|
|
use SleepingOwl\Admin\Contracts\Template\Breadcrumbs as BreadcrumbsContract; |
|
7
|
|
|
|
|
8
|
|
|
class Breadcrumbs extends BreadcrumbsManager implements BreadcrumbsContract |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @param string|null $name |
|
12
|
|
|
* |
|
13
|
|
|
* @return string |
|
14
|
|
|
*/ |
|
15
|
|
|
public function render($name = null) |
|
16
|
|
|
{ |
|
17
|
|
|
if (is_null($name)) { |
|
18
|
|
|
list($name, $params) = $this->currentRoute->get(); |
|
19
|
|
|
} else { |
|
20
|
|
|
$params = array_slice(func_get_args(), 1); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
return $this->view($this->generator->generate($this->callbacks, $name, $params)); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string|null $name |
|
28
|
|
|
* |
|
29
|
|
|
* @return string |
|
30
|
|
|
*/ |
|
31
|
|
|
public function renderIfExists($name = null) |
|
32
|
|
|
{ |
|
33
|
|
|
if (is_null($name)) { |
|
34
|
|
|
list($name, $params) = $this->currentRoute->get(); |
|
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
if (! $this->exists($name)) { |
|
38
|
|
|
return ''; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return $this->render($name); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param string $name |
|
46
|
|
|
* @param array $params |
|
47
|
|
|
* |
|
48
|
|
|
* @return string |
|
49
|
|
|
*/ |
|
50
|
|
|
public function renderArray($name, $params = []) |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->view($this->generator->generate($this->callbacks, $name, $params)); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @param string $name |
|
57
|
|
|
* @param array $params |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
public function renderIfExistsArray($name, $params = []) |
|
62
|
|
|
{ |
|
63
|
|
|
if (! $this->exists($name)) { |
|
64
|
|
|
return ''; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
return $this->renderArray($name, $params); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param array $breadcrumbs |
|
72
|
|
|
* |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function view(array $breadcrumbs) |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->view->render($this->viewName, $breadcrumbs); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
This checks looks for assignemnts to variables using the
list(...)function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$aand$care used. There was no need to assign$b.Instead, the list call could have been.