1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Provider; |
13
|
|
|
|
14
|
|
|
use Twig_Environment; |
15
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\Application\ApplicationProviderInterface; |
16
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\Breadcrumbs\BreadcrumbsProviderInterface; |
17
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\DropDown\DropDownHookProviderInterface; |
18
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\DropDown\DropDownNotificationsProviderInterface; |
19
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\DropDown\DropDownTasksProviderInterface; |
20
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\Footer\FooterProviderInterface; |
21
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\Navigation\NavigationProviderInterface; |
22
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\Search\SearchProviderInterface; |
23
|
|
|
use WBW\Bundle\BootstrapBundle\Provider\User\UserInfoProviderInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Providers manager. |
27
|
|
|
* |
28
|
|
|
* @author webeweb <https://github.com/webeweb/> |
29
|
|
|
* @package WBW\Bundle\BootstrapBundle\Provider |
30
|
|
|
* @final |
31
|
|
|
*/ |
32
|
|
|
final class ProvidersManager { |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Service name. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.provider.manager"; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Application provider. |
43
|
|
|
* |
44
|
|
|
* @var ApplicationProviderInterface |
45
|
|
|
*/ |
46
|
|
|
private $applicationProvider; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Breadcrumbs provider. |
50
|
|
|
* |
51
|
|
|
* @var BreadcrumbsProviderInterface |
52
|
|
|
*/ |
53
|
|
|
private $breadcrumbsProvider; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Drop down hook provider. |
57
|
|
|
* |
58
|
|
|
* @var DropDownHookProviderInterface |
59
|
|
|
*/ |
60
|
|
|
private $dropDownHookProvider; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Drop down notifications provider. |
64
|
|
|
* |
65
|
|
|
* @var DropDownNotificationsProviderInterface |
66
|
|
|
*/ |
67
|
|
|
private $dropDownNotificationsProvider; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Drop down tasks provider. |
71
|
|
|
* |
72
|
|
|
* @var DropDownTasksProviderInterface |
73
|
|
|
*/ |
74
|
|
|
private $dropDownTasksProvider; |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Footer provider. |
78
|
|
|
* |
79
|
|
|
* @var FooterProviderInterface |
80
|
|
|
*/ |
81
|
|
|
private $footerProvider; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Navigation provider. |
85
|
|
|
* |
86
|
|
|
* @var NavigationProviderInterface |
87
|
|
|
*/ |
88
|
|
|
private $navigationProvider; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Search provider. |
92
|
|
|
* |
93
|
|
|
* @var SearchProviderInterface |
94
|
|
|
*/ |
95
|
|
|
private $searchProvider; |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* Twig service. |
99
|
|
|
* |
100
|
|
|
* @var Twig_Environment |
101
|
|
|
*/ |
102
|
|
|
private $twig; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* User info provider. |
106
|
|
|
* |
107
|
|
|
* @var UserInfoProviderInterface |
108
|
|
|
*/ |
109
|
|
|
private $userInfoProvider; |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Constructor. |
113
|
|
|
* |
114
|
|
|
* @param Twig_Environment $twig The Twig service. |
115
|
|
|
*/ |
116
|
|
|
public function __construct(Twig_Environment $twig) { |
117
|
|
|
$this->twig = $twig; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the application provider. |
122
|
|
|
* |
123
|
|
|
* @return ApplicationProviderInterface Returns the application provider. |
124
|
|
|
*/ |
125
|
|
|
public function getApplicationProvider() { |
126
|
|
|
return $this->applicationProvider; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Get the breadcrumbs provider. |
131
|
|
|
* |
132
|
|
|
* @return BreadcrumbsProviderInterface Returns the breadcrumbs provider. |
133
|
|
|
*/ |
134
|
|
|
public function getBreadcrumbsProvider() { |
135
|
|
|
return $this->breadcrumbsProvider; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Get the drop down hook provider. |
140
|
|
|
* |
141
|
|
|
* @return DropDownHookProviderInterface Returns the drop down hook provider. |
142
|
|
|
*/ |
143
|
|
|
public function getDropDownHookProvider() { |
144
|
|
|
return $this->dropDownHookProvider; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Get the drop down notifications provider. |
149
|
|
|
* |
150
|
|
|
* @return DropDownNotificationsProviderInterface Returns the drop down notifications provider. |
151
|
|
|
*/ |
152
|
|
|
public function getDropDownNotificationsProvider() { |
153
|
|
|
return $this->dropDownNotificationsProvider; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Get the drop down tasks provider. |
158
|
|
|
* |
159
|
|
|
* @return DropDownTasksProviderInterface Returns the drop down tasks provider. |
160
|
|
|
*/ |
161
|
|
|
public function getDropDownTasksProvider() { |
162
|
|
|
return $this->dropDownTasksProvider; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Get the footer provider. |
167
|
|
|
* |
168
|
|
|
* @return FooterProviderInterface Returns the footer provider. |
169
|
|
|
*/ |
170
|
|
|
public function getFooterProvider() { |
171
|
|
|
return $this->footerProvider; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Get the navigation provider. |
176
|
|
|
* |
177
|
|
|
* @return NavigationProviderInterface Returns the navigation provider. |
178
|
|
|
*/ |
179
|
|
|
public function getNavigationProvider() { |
180
|
|
|
return $this->navigationProvider; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Get the search provider. |
185
|
|
|
* |
186
|
|
|
* @return SearchProviderInterface Returns the search provider. |
187
|
|
|
*/ |
188
|
|
|
public function getSearchProvider() { |
189
|
|
|
return $this->searchProvider; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Get the user info provider. |
194
|
|
|
* |
195
|
|
|
* @return UserInfoProviderInterface Returns the user info provider. |
196
|
|
|
*/ |
197
|
|
|
public function getUserInfoProvider() { |
198
|
|
|
return $this->userInfoProvider; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
/** |
202
|
|
|
* Register the providers. |
203
|
|
|
* |
204
|
|
|
* @return void |
205
|
|
|
*/ |
206
|
|
|
public function register() { |
207
|
|
|
$this->twig->addGlobal("ApplicationProvider", $this->applicationProvider); |
208
|
|
|
$this->twig->addGlobal("BreadcrumbsProvider", $this->breadcrumbsProvider); |
209
|
|
|
$this->twig->addGlobal("DropDownHookProvider", $this->dropDownHookProvider); |
210
|
|
|
$this->twig->addGlobal("DropDownNotificationsProvider", $this->dropDownNotificationsProvider); |
211
|
|
|
$this->twig->addGlobal("DropDownTasksProvider", $this->dropDownTasksProvider); |
212
|
|
|
$this->twig->addGlobal("FooterProvider", $this->footerProvider); |
213
|
|
|
$this->twig->addGlobal("NavigationProvider", $this->navigationProvider); |
214
|
|
|
$this->twig->addGlobal("SearchProvider", $this->searchProvider); |
215
|
|
|
$this->twig->addGlobal("UserInfoProvider", $this->userInfoProvider); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Set the application provider. |
220
|
|
|
* |
221
|
|
|
* @param ApplicationProviderInterface $applicationProvider The application provider. |
222
|
|
|
* @return ProvidersManager Returns the providers manager. |
223
|
|
|
*/ |
224
|
|
|
public function setApplicationProvider(ApplicationProviderInterface $applicationProvider) { |
225
|
|
|
$this->applicationProvider = $applicationProvider; |
226
|
|
|
return $this; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
|
/** |
230
|
|
|
* Set the breadcrumbs provider. |
231
|
|
|
* |
232
|
|
|
* @param BreadcrumbsProviderInterface $breadcrumbsProvider The breadcrumbs provider. |
233
|
|
|
* @return ProvidersManager Returns the providers manager. |
234
|
|
|
*/ |
235
|
|
|
public function setBreadcrumbsProvider(BreadcrumbsProviderInterface $breadcrumbsProvider) { |
236
|
|
|
$this->breadcrumbsProvider = $breadcrumbsProvider; |
237
|
|
|
return $this; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* Set the drop down hook provider. |
242
|
|
|
* |
243
|
|
|
* @param DropDownHookProviderInterface $dropDownHookProvider The drop down hook provider. |
244
|
|
|
* @return ProvidersManager Returns the providers manager. |
245
|
|
|
*/ |
246
|
|
|
public function setDropDownHookProvider(DropDownHookProviderInterface $dropDownHookProvider) { |
247
|
|
|
$this->dropDownHookProvider = $dropDownHookProvider; |
248
|
|
|
return $this; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Set the drop down notifications provider. |
253
|
|
|
* |
254
|
|
|
* @param DropDownNotificationsProviderInterface $dropDownNotificationsProvider The drop down notifications provider. |
255
|
|
|
* @return ProvidersManager Returns the providers manager. |
256
|
|
|
*/ |
257
|
|
|
public function setDropDownNotificationsProvider(DropDownNotificationsProviderInterface $dropDownNotificationsProvider) { |
258
|
|
|
$this->dropDownNotificationsProvider = $dropDownNotificationsProvider; |
259
|
|
|
return $this; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Set the drop down tasks provider. |
264
|
|
|
* |
265
|
|
|
* @param DropDownTasksProviderInterface $dropDownTasksProvider The drop down task provider. |
266
|
|
|
* @return ProvidersManager Returns the providers manager. |
267
|
|
|
*/ |
268
|
|
|
public function setDropDownTasksProvider(DropDownTasksProviderInterface $dropDownTasksProvider) { |
269
|
|
|
$this->dropDownTasksProvider = $dropDownTasksProvider; |
270
|
|
|
return $this; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Set the footer provider. |
275
|
|
|
* |
276
|
|
|
* @param FooterProviderInterface $footerProvider The footer priovider. |
277
|
|
|
* @return ProvidersManager Returns the providers manager. |
278
|
|
|
*/ |
279
|
|
|
public function setFooterProvider(FooterProviderInterface $footerProvider) { |
280
|
|
|
$this->footerProvider = $footerProvider; |
281
|
|
|
return $this; |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
/** |
285
|
|
|
* Set the navigation provider. |
286
|
|
|
* |
287
|
|
|
* @param NavigationProviderInterface $navigationProvider The navigation provider. |
288
|
|
|
* @return ProvidersManager Returns the providers manager. |
289
|
|
|
*/ |
290
|
|
|
public function setNavigationProvider(NavigationProviderInterface $navigationProvider) { |
291
|
|
|
$this->navigationProvider = $navigationProvider; |
292
|
|
|
return $this; |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
/** |
296
|
|
|
* Set the search provider. |
297
|
|
|
* |
298
|
|
|
* @param SearchProviderInterface $searchProvider The search provider. |
299
|
|
|
* @return ProvidersManager Returns the providers manager. |
300
|
|
|
*/ |
301
|
|
|
public function setSearchProvider(SearchProviderInterface $searchProvider) { |
302
|
|
|
$this->searchProvider = $searchProvider; |
303
|
|
|
return $this; |
304
|
|
|
} |
305
|
|
|
|
306
|
|
|
/** |
307
|
|
|
* Set the user info provider. |
308
|
|
|
* |
309
|
|
|
* @param UserInfoProviderInterface $userInfoProvider The user info provider. |
310
|
|
|
* @return ProvidersManager Returns the providers manager. |
311
|
|
|
*/ |
312
|
|
|
public function setUserInfoProvider(UserInfoProviderInterface $userInfoProvider) { |
313
|
|
|
$this->userInfoProvider = $userInfoProvider; |
314
|
|
|
return $this; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
} |
318
|
|
|
|