|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2018 |
|
5
|
|
|
* Nathan Boiron <[email protected]> |
|
6
|
|
|
* Romain Canon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
10
|
|
|
* under the terms of the GNU General Public License, either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, see: |
|
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Domain\Definition\Builder\Component; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Definition\Builder\Component\DefinitionComponents; |
|
20
|
|
|
use CuyZ\Notiz\Core\Definition\Builder\Component\Source\DefinitionSource; |
|
21
|
|
|
use CuyZ\Notiz\Core\Support\NotizConstants; |
|
22
|
|
|
use CuyZ\Notiz\Domain\Definition\Builder\Component\Source\TypoScriptDefinitionSource; |
|
23
|
|
|
use CuyZ\Notiz\Service\ExtensionConfigurationService; |
|
24
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
25
|
|
|
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
26
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Service used for registration of default definition components supplied by |
|
30
|
|
|
* the extension. |
|
31
|
|
|
*/ |
|
32
|
|
|
class DefaultDefinitionComponents implements SingletonInterface |
|
33
|
|
|
{ |
|
34
|
|
|
const DEFAULT_DEFINITION_FILE_PRIORITY = 1337; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var bool |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $registrationDone = false; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var ExtensionConfigurationService |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $extensionConfigurationService; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param ExtensionConfigurationService $extensionConfigurationService |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct(ExtensionConfigurationService $extensionConfigurationService) |
|
50
|
|
|
{ |
|
51
|
|
|
$this->extensionConfigurationService = $extensionConfigurationService; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Default definition comes from TypoScript files, so a definition source |
|
56
|
|
|
* must be added to the definition builder and the files must be registered. |
|
57
|
|
|
* |
|
58
|
|
|
* @param DefinitionComponents $components |
|
59
|
|
|
*/ |
|
60
|
|
|
public function register(DefinitionComponents $components) |
|
61
|
|
|
{ |
|
62
|
|
|
if ($this->registrationDone) { |
|
63
|
|
|
return; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
$this->registrationDone = true; |
|
67
|
|
|
|
|
68
|
|
|
/** @var TypoScriptDefinitionSource $typoScriptDefinitionSource */ |
|
69
|
|
|
$typoScriptDefinitionSource = $components->addSource(DefinitionSource::SOURCE_TYPOSCRIPT); |
|
70
|
|
|
|
|
71
|
|
|
foreach ($this->getDefaultFiles() as $file) { |
|
72
|
|
|
$typoScriptDefinitionSource->addFilePath($file, self::DEFAULT_DEFINITION_FILE_PRIORITY); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
|
|
private function getDefaultFiles() |
|
80
|
|
|
{ |
|
81
|
|
|
$defaultFiles = [ |
|
82
|
|
|
NotizConstants::TYPOSCRIPT_PATH . 'Channel/Channels.Default.typoscript', |
|
83
|
|
|
NotizConstants::TYPOSCRIPT_PATH . 'Notification/Notifications.typoscript', |
|
84
|
|
|
]; |
|
85
|
|
|
|
|
86
|
|
|
// TYPO3 events can be enabled/disabled in the extension configuration. |
|
87
|
|
|
if ($this->extensionConfigurationService->getConfigurationValue('events.typo3')) { |
|
88
|
|
|
$defaultFiles[] = NotizConstants::TYPOSCRIPT_PATH . 'Event/Events.TYPO3.typoscript'; |
|
89
|
|
|
|
|
90
|
|
|
if (ExtensionManagementUtility::isLoaded('scheduler')) { |
|
91
|
|
|
$defaultFiles[] = NotizConstants::TYPOSCRIPT_PATH . 'Event/Events.Scheduler.typoscript'; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// The core extension "form" can dispatch events. |
|
96
|
|
|
if (ExtensionManagementUtility::isLoaded('form') |
|
97
|
|
|
&& version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '>=') |
|
98
|
|
|
) { |
|
99
|
|
|
$defaultFiles[] = NotizConstants::TYPOSCRIPT_PATH . 'Event/Events.Form.typoscript'; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
return $defaultFiles; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|