1 | <?php |
||
27 | class BreadcrumbsBuilder |
||
28 | { |
||
29 | /** |
||
30 | * @var RequestStack |
||
31 | */ |
||
32 | private $requestStack; |
||
33 | |||
34 | /** |
||
35 | * @var Request |
||
36 | */ |
||
37 | private $request; |
||
38 | |||
39 | /** |
||
40 | * @var Router |
||
41 | */ |
||
42 | private $router; |
||
43 | |||
44 | /** |
||
45 | * @var TraceableUrlMatcher |
||
46 | */ |
||
47 | private $matcher; |
||
48 | |||
49 | public function __construct(Router $router, RequestStack $requestStack = null) |
||
50 | { |
||
51 | $this->router = $router; |
||
52 | $this->requestStack = $requestStack; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * BC with SF 2.3 |
||
57 | * |
||
58 | * @param Request|null $request |
||
59 | */ |
||
60 | public function setRequest(Request $request = null) |
||
64 | |||
65 | /** |
||
66 | * Create a empty breadcrumb |
||
67 | * |
||
68 | * @return Breadcrumbs |
||
69 | */ |
||
70 | public function create() |
||
74 | |||
75 | /** |
||
76 | * Create a breadcrumb through current request path |
||
77 | * |
||
78 | * @return Breadcrumbs |
||
79 | */ |
||
80 | public function createFromRequest() |
||
99 | |||
100 | /** |
||
101 | * Get all breadcrumbs paths from current request path |
||
102 | * |
||
103 | * @return array of string |
||
104 | */ |
||
105 | private function getBreadcrumbsPaths() |
||
130 | |||
131 | /** |
||
132 | * Create a breadcrumbs node from path |
||
133 | * |
||
134 | * @param string $path |
||
135 | * @param string $parent |
||
136 | * |
||
137 | * @return BreadcrumbsNode|bool |
||
138 | */ |
||
139 | private function createBreadcrumbsNode($path, $parent) |
||
159 | |||
160 | private function getRequest() |
||
164 | |||
165 | /** |
||
166 | * Get label |
||
167 | * |
||
168 | * @param $path |
||
169 | * @param $parent |
||
170 | * @param $name |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | private function getLabel($path, $parent, $name) |
||
207 | } |
||
208 |