1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-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\CoreBundle\Manager; |
13
|
|
|
|
14
|
|
|
use Throwable; |
15
|
|
|
use WBW\Library\Symfony\Manager\ManagerInterface; |
16
|
|
|
use WBW\Library\Symfony\Provider\Theme\ApplicationThemeProviderInterface; |
17
|
|
|
use WBW\Library\Symfony\Provider\Theme\BreadcrumbsThemeProviderInterface; |
18
|
|
|
use WBW\Library\Symfony\Provider\Theme\FooterThemeProviderInterface; |
19
|
|
|
use WBW\Library\Symfony\Provider\Theme\HookDropdownThemeProviderInterface; |
20
|
|
|
use WBW\Library\Symfony\Provider\Theme\NavigationThemeProviderInterface; |
21
|
|
|
use WBW\Library\Symfony\Provider\Theme\NotificationsDropdownThemeProviderInterface; |
22
|
|
|
use WBW\Library\Symfony\Provider\Theme\SearchThemeProviderInterface; |
23
|
|
|
use WBW\Library\Symfony\Provider\Theme\TasksDropdownThemeProviderInterface; |
24
|
|
|
use WBW\Library\Symfony\Provider\Theme\UserInfoThemeProviderInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Theme manager. |
28
|
|
|
* |
29
|
|
|
* @author webeweb <https://github.com/webeweb> |
30
|
|
|
* @package WBW\Bundle\CoreBundle\Manager |
31
|
|
|
*/ |
32
|
|
|
class ThemeManager extends AbstractThemeManager { |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Service name. |
36
|
|
|
* |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
const SERVICE_NAME = "wbw.core.manager.theme"; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get the application theme provider. |
43
|
|
|
* |
44
|
30 |
|
* @return ApplicationThemeProviderInterface|null Returns the application theme provider. |
45
|
30 |
|
*/ |
46
|
|
|
public function getApplicationThemeProvider(): ?ApplicationThemeProviderInterface { |
47
|
|
|
return $this->getProvider(ApplicationThemeProviderInterface::class); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Get the breadcrumbs theme provider. |
52
|
|
|
* |
53
|
30 |
|
* @return BreadcrumbsThemeProviderInterface|null Returns the breadcrumbs theme provider. |
54
|
30 |
|
*/ |
55
|
|
|
public function getBreadcrumbsThemeProvider(): ?BreadcrumbsThemeProviderInterface { |
56
|
|
|
return $this->getProvider(BreadcrumbsThemeProviderInterface::class); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the footer theme provider. |
61
|
|
|
* |
62
|
30 |
|
* @return FooterThemeProviderInterface|null Returns the footer theme provider. |
63
|
30 |
|
*/ |
64
|
|
|
public function getFooterThemeProvider(): ?FooterThemeProviderInterface { |
65
|
|
|
return $this->getProvider(FooterThemeProviderInterface::class); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get the hook drop down theme provider. |
70
|
|
|
* |
71
|
30 |
|
* @return HookDropdownThemeProviderInterface|null Returns the hook drop down theme provider. |
72
|
30 |
|
*/ |
73
|
|
|
public function getHookDropdownThemeProvider(): ?HookDropdownThemeProviderInterface { |
74
|
|
|
return $this->getProvider(HookDropdownThemeProviderInterface::class); |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Get the navigation theme provider. |
79
|
|
|
* |
80
|
20 |
|
* @return NavigationThemeProviderInterface|null Returns the navigation theme provider. |
81
|
20 |
|
*/ |
82
|
|
|
public function getNavigationThemeProvider(): ?NavigationThemeProviderInterface { |
83
|
|
|
return $this->getProvider(NavigationThemeProviderInterface::class); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Get the notifications drop down theme provider. |
88
|
|
|
* |
89
|
30 |
|
* @return NotificationsDropdownThemeProviderInterface|null Returns the Notifications drop down theme provider. |
90
|
30 |
|
*/ |
91
|
|
|
public function getNotificationsDropdownThemeProvider(): ?NotificationsDropdownThemeProviderInterface { |
92
|
|
|
return $this->getProvider(NotificationsDropdownThemeProviderInterface::class); |
|
|
|
|
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get the search theme provider. |
97
|
|
|
* |
98
|
30 |
|
* @return SearchThemeProviderInterface|null Returns the search theme provider. |
99
|
30 |
|
*/ |
100
|
|
|
public function getSearchThemeProvider(): ?SearchThemeProviderInterface { |
101
|
|
|
return $this->getProvider(SearchThemeProviderInterface::class); |
|
|
|
|
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Get the tasks drop down theme provider. |
106
|
|
|
* |
107
|
30 |
|
* @return TasksDropdownThemeProviderInterface|null Returns the tasks drop down theme provider. |
108
|
30 |
|
*/ |
109
|
|
|
public function getTasksDropdownThemeProvider(): ?TasksDropdownThemeProviderInterface { |
110
|
|
|
return $this->getProvider(TasksDropdownThemeProviderInterface::class); |
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Get the user info theme provider. |
115
|
|
|
* |
116
|
30 |
|
* @return UserInfoThemeProviderInterface|null Returns the user info theme provider. |
117
|
30 |
|
*/ |
118
|
|
|
public function getUserInfoThemeProvider(): ?UserInfoThemeProviderInterface { |
119
|
|
|
return $this->getProvider(UserInfoThemeProviderInterface::class); |
|
|
|
|
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
280 |
|
* {@inheritDoc} |
124
|
|
|
*/ |
125
|
280 |
|
protected function initIndex(): array { |
126
|
|
|
|
127
|
|
|
return [ |
128
|
|
|
ApplicationThemeProviderInterface::class => null, |
129
|
|
|
BreadcrumbsThemeProviderInterface::class => null, |
130
|
|
|
FooterThemeProviderInterface::class => null, |
131
|
|
|
HookDropdownThemeProviderInterface::class => null, |
132
|
|
|
NavigationThemeProviderInterface::class => null, |
133
|
|
|
NotificationsDropdownThemeProviderInterface::class => null, |
134
|
|
|
SearchThemeProviderInterface::class => null, |
135
|
|
|
TasksDropdownThemeProviderInterface::class => null, |
136
|
|
|
UserInfoThemeProviderInterface::class => null, |
137
|
|
|
]; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Set the application theme provider. |
142
|
|
|
* |
143
|
80 |
|
* @param ApplicationThemeProviderInterface $provider The application theme provider. |
144
|
80 |
|
* @return ManagerInterface Returns this manager. |
145
|
80 |
|
* @throws Throwable Throws an exception if an error occurs. |
146
|
|
|
*/ |
147
|
|
|
public function setApplicationThemeProvider(ApplicationThemeProviderInterface $provider): ManagerInterface { |
148
|
|
|
$this->setProvider(ApplicationThemeProviderInterface::class, $provider); |
149
|
|
|
return $this; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Set the breadcrumbs theme provider. |
154
|
70 |
|
* |
155
|
70 |
|
* @param BreadcrumbsThemeProviderInterface $provider The breadcrumbs theme provider. |
156
|
70 |
|
* @return ManagerInterface Returns this manager. |
157
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
158
|
|
|
*/ |
159
|
|
|
public function setBreadcrumbsThemeProvider(BreadcrumbsThemeProviderInterface $provider): ManagerInterface { |
160
|
|
|
$this->setProvider(BreadcrumbsThemeProviderInterface::class, $provider); |
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
70 |
|
* Set the footer theme provider. |
166
|
70 |
|
* |
167
|
70 |
|
* @param FooterThemeProviderInterface $provider The footer theme provider. |
168
|
|
|
* @return ManagerInterface Returns this manager. |
169
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
170
|
|
|
*/ |
171
|
|
|
public function setFooterThemeProvider(FooterThemeProviderInterface $provider): ManagerInterface { |
172
|
|
|
$this->setProvider(FooterThemeProviderInterface::class, $provider); |
173
|
|
|
return $this; |
174
|
|
|
} |
175
|
|
|
|
176
|
70 |
|
/** |
177
|
70 |
|
* Set the hook drop down theme provider. |
178
|
70 |
|
* |
179
|
|
|
* @param HookDropdownThemeProviderInterface $provider The hook drop down theme provider. |
180
|
|
|
* @return ManagerInterface Returns this manager. |
181
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
182
|
|
|
*/ |
183
|
|
|
public function setHookDropdownThemeProvider(HookDropdownThemeProviderInterface $provider): ManagerInterface { |
184
|
|
|
$this->setProvider(HookDropdownThemeProviderInterface::class, $provider); |
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
20 |
|
|
188
|
20 |
|
/** |
189
|
20 |
|
* Set the navigation theme provider. |
190
|
|
|
* |
191
|
|
|
* @param NavigationThemeProviderInterface $provider The navigation theme provider. |
192
|
|
|
* @return ManagerInterface Returns this manager. |
193
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
194
|
|
|
*/ |
195
|
|
|
public function setNavigationThemeProvider(NavigationThemeProviderInterface $provider): ManagerInterface { |
196
|
|
|
$this->setProvider(NavigationThemeProviderInterface::class, $provider); |
197
|
|
|
return $this; |
198
|
70 |
|
} |
199
|
70 |
|
|
200
|
70 |
|
/** |
201
|
|
|
* Set the notifications drop down theme provider. |
202
|
|
|
* |
203
|
|
|
* @param NotificationsDropdownThemeProviderInterface $provider The notifications drop down theme provider. |
204
|
|
|
* @return ManagerInterface Returns this manager. |
205
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
206
|
|
|
*/ |
207
|
|
|
public function setNotificationsDropdownThemeProvider(NotificationsDropdownThemeProviderInterface $provider): ManagerInterface { |
208
|
|
|
$this->setProvider(NotificationsDropdownThemeProviderInterface::class, $provider); |
209
|
70 |
|
return $this; |
210
|
70 |
|
} |
211
|
70 |
|
|
212
|
|
|
/** |
213
|
|
|
* Set the search theme provider. |
214
|
|
|
* |
215
|
|
|
* @param SearchThemeProviderInterface $provider The search theme provider. |
216
|
|
|
* @return ManagerInterface Returns this manager. |
217
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
218
|
|
|
*/ |
219
|
|
|
public function setSearchThemeProvider(SearchThemeProviderInterface $provider): ManagerInterface { |
220
|
70 |
|
$this->setProvider(SearchThemeProviderInterface::class, $provider); |
221
|
70 |
|
return $this; |
222
|
70 |
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* Set the tasks drop down theme provider. |
226
|
|
|
* |
227
|
|
|
* @param TasksDropdownThemeProviderInterface $provider The tasks drop down theme provider. |
228
|
|
|
* @return ManagerInterface Returns this manager. |
229
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
230
|
|
|
*/ |
231
|
70 |
|
public function setTasksDropdownThemeProvider(TasksDropdownThemeProviderInterface $provider): ManagerInterface { |
232
|
70 |
|
$this->setProvider(TasksDropdownThemeProviderInterface::class, $provider); |
233
|
70 |
|
return $this; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Set the user info theme provider. |
238
|
|
|
* |
239
|
|
|
* @param UserInfoThemeProviderInterface $provider The user info theme provider. |
240
|
|
|
* @return ManagerInterface Returns this manager. |
241
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
242
|
|
|
*/ |
243
|
|
|
public function setUserInfoThemeProvider(UserInfoThemeProviderInterface $provider): ManagerInterface { |
244
|
|
|
$this->setProvider(UserInfoThemeProviderInterface::class, $provider); |
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|