|
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\Core\Definition\Tree\EventGroup\Event\Configuration; |
|
19
|
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; |
|
21
|
|
|
use CuyZ\Notiz\Core\Event\Configuration\FlexForm\DefaultEventFlexFormProvider; |
|
22
|
|
|
use CuyZ\Notiz\Core\Event\Configuration\FlexForm\EventFlexFormProvider; |
|
23
|
|
|
use CuyZ\Notiz\Core\Exception\ClassNotFoundException; |
|
24
|
|
|
use CuyZ\Notiz\Core\Exception\InvalidClassException; |
|
25
|
|
|
use CuyZ\Notiz\Core\Exception\NotizException; |
|
26
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor; |
|
27
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface; |
|
28
|
|
|
use TYPO3\CMS\Extbase\Validation\Error; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
class EventConfiguration extends AbstractDefinitionComponent implements DataPreProcessorInterface |
|
31
|
|
|
{ |
|
32
|
|
|
const DEFAULT_PROVIDER = DefaultEventFlexFormProvider::class; |
|
33
|
|
|
|
|
34
|
|
|
const PROVIDER_CLASS_NAME = '__notiz_event_configuration_flexForm_provider'; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var \CuyZ\Notiz\Core\Event\Configuration\FlexForm\EventFlexFormProvider |
|
38
|
|
|
* |
|
39
|
|
|
* @mixedTypesResolver \CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\Configuration\FlexForm\EventFlexFormResolver |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $flexForm; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return EventFlexFormProvider |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getFlexFormProvider(): EventFlexFormProvider |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->flexForm; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Pre-fills properties for this class. |
|
53
|
|
|
* |
|
54
|
|
|
* @param DataPreProcessor $processor |
|
55
|
|
|
*/ |
|
56
|
|
|
public static function dataPreProcessor(DataPreProcessor $processor) |
|
57
|
|
|
{ |
|
58
|
|
|
$data = $processor->getData(); |
|
59
|
|
|
|
|
60
|
|
|
if (!isset($data['flexForm'])) { |
|
61
|
|
|
$data['flexForm'] = []; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$data['flexForm'][self::PROVIDER_CLASS_NAME] = self::DEFAULT_PROVIDER; |
|
65
|
|
|
|
|
66
|
|
|
try { |
|
67
|
|
|
$data = self::setFlexFormProviderClassName($data); |
|
68
|
|
|
} catch (NotizException $exception) { |
|
69
|
|
|
$error = new Error($exception->getMessage(), $exception->getCode()); |
|
70
|
|
|
$processor->addError($error); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$processor->setData($data); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Checks the provider class name validity. If it is valid, the value is |
|
78
|
|
|
* added to the data array to be passed to the child property (the resolver |
|
79
|
|
|
* will use it to instantiate the class later). |
|
80
|
|
|
* |
|
81
|
|
|
* @param array $data |
|
82
|
|
|
* @return array |
|
83
|
|
|
* |
|
84
|
|
|
* @throws ClassNotFoundException |
|
85
|
|
|
* @throws InvalidClassException |
|
86
|
|
|
*/ |
|
87
|
|
|
protected static function setFlexFormProviderClassName(array $data): array |
|
88
|
|
|
{ |
|
89
|
|
|
if (isset($data['flexFormProviderClassName'])) { |
|
90
|
|
|
$className = $data['flexFormProviderClassName']; |
|
91
|
|
|
|
|
92
|
|
|
if (!class_exists($className)) { |
|
93
|
|
|
throw ClassNotFoundException::eventConfigurationFlexFormProviderClassNotFound($className); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
if (!in_array(EventFlexFormProvider::class, class_implements($className))) { |
|
97
|
|
|
throw InvalidClassException::eventConfigurationFlexFormProviderMissingInterface($className); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
$data['flexForm'][self::PROVIDER_CLASS_NAME] = $data['flexFormProviderClassName']; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $data; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
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