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