1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* Copyright (C) 2018 |
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; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Exception\EntryNotFoundException; |
21
|
|
|
use CuyZ\Notiz\Core\Support\NotizConstants; |
22
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
23
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
24
|
|
|
use TYPO3\CMS\Core\Utility\ArrayUtility; |
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
26
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
27
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
|
|
|
28
|
|
|
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility; |
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Service to ease the reading of the extension configuration written in the |
32
|
|
|
* file `ext_conf_template.txt`. |
33
|
|
|
*/ |
34
|
|
|
class ExtensionConfigurationService implements SingletonInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @param string $key |
38
|
|
|
* @return mixed |
39
|
|
|
* |
40
|
|
|
* @throws EntryNotFoundException |
41
|
|
|
*/ |
42
|
|
|
public function getConfigurationValue(string $key) |
43
|
|
|
{ |
44
|
|
|
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '9.0.0', '<')) { |
45
|
|
|
return $this->getConfigurationValueLegacy($key); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/* |
49
|
|
|
* @deprecated When TYPO3 v8 is not supported anymore, inject this |
50
|
|
|
* service in constructor and fill a class property `$configuration` |
51
|
|
|
* for memoization. |
52
|
|
|
*/ |
53
|
|
|
$extensionConfiguration = $this->objectManager()->get(ExtensionConfiguration::class); |
54
|
|
|
|
55
|
|
|
$configuration = $extensionConfiguration->get(NotizConstants::EXTENSION_KEY); |
56
|
|
|
|
57
|
|
|
if (!ArrayUtility::isValidPath($configuration, $key, '.')) { |
58
|
|
|
throw EntryNotFoundException::extensionConfigurationEntryNotFound($key); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return ArrayUtility::getValueByPath($configuration, $key, '.'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $key |
66
|
|
|
* @return mixed |
67
|
|
|
* |
68
|
|
|
* @throws EntryNotFoundException |
69
|
|
|
*/ |
70
|
|
|
private function getConfigurationValueLegacy(string $key) |
71
|
|
|
{ |
72
|
|
|
$configurationUtility = $this->objectManager()->get(ConfigurationUtility::class); |
73
|
|
|
$configuration = $configurationUtility->getCurrentConfiguration(NotizConstants::EXTENSION_KEY); |
74
|
|
|
|
75
|
|
|
if (!isset($configuration[$key]['value'])) { |
76
|
|
|
throw EntryNotFoundException::extensionConfigurationEntryNotFound($key); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return $configuration[$key]['value']; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return ObjectManager |
84
|
|
|
*/ |
85
|
|
|
private function objectManager(): ObjectManager |
86
|
|
|
{ |
87
|
|
|
/** @noinspection PhpIncompatibleReturnTypeInspection */ |
88
|
|
|
return GeneralUtility::makeInstance(ObjectManager::class); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
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