1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Copyright (C) |
6
|
|
|
* Nathan Boiron <[email protected]> |
7
|
|
|
* Romain Canon <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This file is part of the TYPO3 NotiZ project. |
10
|
|
|
* It is free software; you can redistribute it and/or modify it |
11
|
|
|
* under the terms of the GNU General Public License, either |
12
|
|
|
* version 3 of the License, or any later version. |
13
|
|
|
* |
14
|
|
|
* For the full copyright and license information, see: |
15
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
namespace CuyZ\Notiz\Service\Extension; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Backend\FormEngine\DataProvider\DefaultEventFromGet; |
21
|
|
|
use CuyZ\Notiz\Backend\FormEngine\DataProvider\DefinitionError; |
22
|
|
|
use CuyZ\Notiz\Backend\FormEngine\DataProvider\HideColumns; |
23
|
|
|
use CuyZ\Notiz\Backend\ToolBarItems\NotificationsToolbarItem; |
24
|
|
|
use CuyZ\Notiz\Core\Definition\Builder\DefinitionBuilder; |
25
|
|
|
use CuyZ\Notiz\Core\Notification\TCA\Processor\GracefulProcessorRunner; |
26
|
|
|
use CuyZ\Notiz\Core\Support\NotizConstants; |
27
|
|
|
use CuyZ\Notiz\Domain\Definition\Builder\Component\DefaultDefinitionComponents; |
28
|
|
|
use CuyZ\Notiz\Domain\Event\Blog\Processor\BlogNotificationProcessor; |
29
|
|
|
use CuyZ\Notiz\Service\Container; |
30
|
|
|
use CuyZ\Notiz\Service\ExtensionConfigurationService; |
31
|
|
|
use CuyZ\Notiz\Service\Hook\EventDefinitionRegisterer; |
32
|
|
|
use CuyZ\Notiz\Service\Traits\SelfInstantiateTrait; |
33
|
|
|
use Doctrine\Common\Annotations\AnnotationReader; |
34
|
|
|
use T3G\AgencyPack\Blog\Notification\CommentAddedNotification; |
|
|
|
|
35
|
|
|
use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseEditRow; |
|
|
|
|
36
|
|
|
use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordOverrideValues; |
|
|
|
|
37
|
|
|
use TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca; |
|
|
|
|
38
|
|
|
use TYPO3\CMS\Core\Cache\Backend\FileBackend; |
39
|
|
|
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend; |
40
|
|
|
use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface; |
41
|
|
|
use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider; |
42
|
|
|
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider; |
43
|
|
|
use TYPO3\CMS\Core\Imaging\IconRegistry; |
44
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
45
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
46
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
47
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
48
|
|
|
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; |
|
|
|
|
49
|
|
|
use TYPO3\CMS\Scheduler\Scheduler; |
|
|
|
|
50
|
|
|
|
51
|
|
|
use function version_compare; |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* This class replaces the old-school procedural way of handling configuration |
55
|
|
|
* in `ext_localconf.php` file. |
56
|
|
|
* |
57
|
|
|
* @internal |
58
|
|
|
*/ |
59
|
|
|
class LocalConfigurationService implements SingletonInterface, TableConfigurationPostProcessingHookInterface |
60
|
|
|
{ |
61
|
|
|
use SelfInstantiateTrait; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @var IconRegistry |
65
|
|
|
*/ |
66
|
|
|
protected $iconRegistry; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var Dispatcher |
70
|
|
|
*/ |
71
|
|
|
protected $dispatcher; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @var ExtensionConfigurationService |
75
|
|
|
*/ |
76
|
|
|
protected $extensionConfigurationService; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Manual dependency injection. |
80
|
|
|
*/ |
81
|
|
|
public function __construct() |
82
|
|
|
{ |
83
|
|
|
$this->dispatcher = GeneralUtility::makeInstance(Dispatcher::class); |
84
|
|
|
$this->iconRegistry = GeneralUtility::makeInstance(IconRegistry::class); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Main processing methods that will call every method of this class. |
89
|
|
|
*/ |
90
|
|
|
public function process() |
91
|
|
|
{ |
92
|
|
|
$this->registerLaterProcessHook(); |
93
|
|
|
$this->registerDefinitionComponents(); |
94
|
|
|
$this->registerEventDefinitionHook(); |
95
|
|
|
$this->registerInternalCache(); |
96
|
|
|
$this->registerIcons(); |
97
|
|
|
$this->registerNotificationProcessorRunner(); |
98
|
|
|
$this->registerFormEngineComponents(); |
99
|
|
|
$this->resetTypeConvertersArray(); |
|
|
|
|
100
|
|
|
$this->overrideScheduler(); |
101
|
|
|
$this->ignoreDoctrineAnnotation(); |
102
|
|
|
$this->registerBlogNotificationProcessors(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* This is the second part of the process. |
107
|
|
|
* |
108
|
|
|
* Because the `ExtensionConfigurationService` needs the database to be |
109
|
|
|
* initialized (Extbase reflection service may need it), we need to hook |
110
|
|
|
* later in the TYPO3 bootstrap process to ensure everything has been |
111
|
|
|
* initialized. |
112
|
|
|
* |
113
|
|
|
* @see \CuyZ\Notiz\Service\Extension\LocalConfigurationService::registerLaterProcessHook |
114
|
|
|
*/ |
115
|
|
|
public function processData() |
116
|
|
|
{ |
117
|
|
|
$this->extensionConfigurationService = Container::get(ExtensionConfigurationService::class); |
118
|
|
|
|
119
|
|
|
$this->registerToolBarItem(); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @see \CuyZ\Notiz\Service\Extension\LocalConfigurationService::processData |
124
|
|
|
*/ |
125
|
|
|
protected function registerLaterProcessHook() |
126
|
|
|
{ |
127
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = static::class; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Connects a slot on the definition components customization signal. |
132
|
|
|
*/ |
133
|
|
|
protected function registerDefinitionComponents() |
134
|
|
|
{ |
135
|
|
|
$this->dispatcher->connect( |
136
|
|
|
DefinitionBuilder::class, |
137
|
|
|
DefinitionBuilder::COMPONENTS_SIGNAL, |
138
|
|
|
DefaultDefinitionComponents::class, |
139
|
|
|
'register' |
140
|
|
|
); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Hooking in TYPO3 early process to register all hooks/signals added to the |
145
|
|
|
* event definition. |
146
|
|
|
*/ |
147
|
|
|
protected function registerEventDefinitionHook() |
148
|
|
|
{ |
149
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = EventDefinitionRegisterer::class; |
150
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['checkAlternativeIdMethods-PostProc'][] = EventDefinitionRegisterer::class . '->processData'; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Internal cache used by the extension. |
155
|
|
|
*/ |
156
|
|
|
protected function registerInternalCache() |
157
|
|
|
{ |
158
|
|
|
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][NotizConstants::CACHE_ID])) { |
159
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][NotizConstants::CACHE_ID] = [ |
160
|
|
|
'backend' => FileBackend::class, |
161
|
|
|
'frontend' => VariableFrontend::class, |
162
|
|
|
'groups' => ['all', 'system', 'pages'], |
163
|
|
|
]; |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
/** |
168
|
|
|
* Registers icons that can then be used wherever in TYPO3 with the icon |
169
|
|
|
* API. |
170
|
|
|
*/ |
171
|
|
|
protected function registerIcons() |
172
|
|
|
{ |
173
|
|
|
$iconsList = [ |
174
|
|
|
SvgIconProvider::class => [ |
175
|
|
|
'tx-notiz-icon' => ['source' => NotizConstants::EXTENSION_ICON_DEFAULT], |
176
|
|
|
'tx-notiz-icon-toolbar' => ['source' => NotizConstants::EXTENSION_ICON_PATH . 'notiz-icon-toolbar.svg'], |
177
|
|
|
'tx-notiz-icon-main-module' => ['source' => NotizConstants::EXTENSION_ICON_MAIN_MODULE_PATH], |
178
|
|
|
], |
179
|
|
|
FontawesomeIconProvider::class => [ |
180
|
|
|
'info-circle' => ['name' => 'info-circle'], |
181
|
|
|
'envelope' => ['name' => 'envelope'], |
182
|
|
|
'twitter' => ['name' => 'twitter'], |
183
|
|
|
'slack' => ['name' => 'slack'], |
184
|
|
|
'github' => ['name' => 'github'], |
185
|
|
|
], |
186
|
|
|
]; |
187
|
|
|
|
188
|
|
|
foreach ($iconsList as $provider => $icons) { |
189
|
|
|
foreach ($icons as $name => $configuration) { |
190
|
|
|
$this->iconRegistry->registerIcon($name, $provider, $configuration); |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Registers the tool bar item shown on the header of the TYPO3 backend. |
197
|
|
|
*/ |
198
|
|
|
protected function registerToolBarItem() |
199
|
|
|
{ |
200
|
|
|
$enableToolbar = $this->extensionConfigurationService->getConfigurationValue('toolbar.enable'); |
201
|
|
|
|
202
|
|
|
if ($enableToolbar) { |
203
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['BE']['toolbarItems'][1505997677] = NotificationsToolbarItem::class; |
204
|
|
|
} |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Because of some core issue concerning the type converters registration, |
209
|
|
|
* we need to make sure the array containing the entries is valid. |
210
|
|
|
* |
211
|
|
|
* See the ticket below for more information: |
212
|
|
|
* |
213
|
|
|
* @link https://forge.typo3.org/issues/82651 |
214
|
|
|
* |
215
|
|
|
* @deprecated Must be removed when TYPO3 v8 is not supported anymore. |
216
|
|
|
*/ |
217
|
|
|
protected function resetTypeConvertersArray() |
218
|
|
|
{ |
219
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters'] = array_unique($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['typeConverters']); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Registering a xClass that overrides core scheduler, to have access to |
224
|
|
|
* signals for when tasks are executed. |
225
|
|
|
* |
226
|
|
|
* @see \CuyZ\Notiz\Service\Scheduler\Scheduler |
227
|
|
|
*/ |
228
|
|
|
protected function overrideScheduler() |
229
|
|
|
{ |
230
|
|
|
if (ExtensionManagementUtility::isLoaded('scheduler')) { |
231
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][Scheduler::class] = ['className' => \CuyZ\Notiz\Service\Scheduler\Scheduler::class]; |
232
|
|
|
} |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Registers the notification processor runner. |
237
|
|
|
* |
238
|
|
|
* @see \CuyZ\Notiz\Core\Notification\TCA\Processor\GracefulProcessorRunner |
239
|
|
|
*/ |
240
|
|
|
protected function registerNotificationProcessorRunner() |
241
|
|
|
{ |
242
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing'][] = GracefulProcessorRunner::class; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Registers components for TYPO3 form engine. |
247
|
|
|
*/ |
248
|
|
|
protected function registerFormEngineComponents() |
249
|
|
|
{ |
250
|
|
|
/* |
251
|
|
|
* A new data provider is registered for the form engine. |
252
|
|
|
* |
253
|
|
|
* It will be used to select a default value for the field `event` of a |
254
|
|
|
* notification record, if an argument `selectedEvent` exists in the |
255
|
|
|
* request and matches a valid event identifier. |
256
|
|
|
*/ |
257
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][DefaultEventFromGet::class] = ['depends' => [DatabaseEditRow::class]]; |
258
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][DatabaseRecordOverrideValues::class]['depends'][] = DefaultEventFromGet::class; |
259
|
|
|
|
260
|
|
|
/* |
261
|
|
|
* A data provider will be used to detect any definition error, in which |
262
|
|
|
* case an error message is shown to the user trying to create/edit an |
263
|
|
|
* entity notification. |
264
|
|
|
*/ |
265
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][DefinitionError::class] = []; |
266
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][InitializeProcessedTca::class]['depends'][] = DefinitionError::class; |
267
|
|
|
|
268
|
|
|
/* |
269
|
|
|
* A data provider is used to hide all columns when no event has been |
270
|
|
|
* selected for a notification entity. |
271
|
|
|
*/ |
272
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][HideColumns::class] = []; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* Some annotations are used by this extension and can be confusing for |
277
|
|
|
* Doctrine. |
278
|
|
|
*/ |
279
|
|
|
protected function ignoreDoctrineAnnotation() |
280
|
|
|
{ |
281
|
|
|
if (class_exists(AnnotationReader::class)) { |
282
|
|
|
AnnotationReader::addGlobalIgnoredName('label'); |
283
|
|
|
AnnotationReader::addGlobalIgnoredName('marker'); |
284
|
|
|
AnnotationReader::addGlobalIgnoredName('email'); |
285
|
|
|
} |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* Registering a blog processor for each notification it provides. |
290
|
|
|
*/ |
291
|
|
|
protected function registerBlogNotificationProcessors() |
292
|
|
|
{ |
293
|
|
|
if (ExtensionManagementUtility::isLoaded('blog') |
294
|
|
|
&& version_compare(ExtensionManagementUtility::getExtensionVersion('blog'), '9.0.0', '>') |
295
|
|
|
) { |
296
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['Blog']['notificationRegistry'][CommentAddedNotification::class][] = BlogNotificationProcessor::class; |
297
|
|
|
} |
298
|
|
|
} |
299
|
|
|
} |
300
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths