|
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\Connection; |
|
19
|
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Exception\EntryNotFoundException; |
|
21
|
|
|
use CuyZ\Notiz\Core\Exception\InvalidTypeException; |
|
22
|
|
|
use CuyZ\Notiz\Core\Exception\NotizException; |
|
23
|
|
|
use Romm\ConfigurationObject\Service\Items\MixedTypes\MixedTypesInterface; |
|
24
|
|
|
use Romm\ConfigurationObject\Service\Items\MixedTypes\MixedTypesResolver; |
|
25
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
26
|
|
|
use TYPO3\CMS\Extbase\Error\Error; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Resolver for the property: |
|
30
|
|
|
* |
|
31
|
|
|
* @see \CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition::$connection |
|
32
|
|
|
*/ |
|
33
|
|
|
class ConnectionResolver implements SingletonInterface, MixedTypesInterface |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var array |
|
37
|
|
|
*/ |
|
38
|
|
|
protected static $allowedTypes = [ |
|
39
|
|
|
'signal' => Signal::TYPE_SIGNAL, |
|
40
|
|
|
'hook' => Signal::TYPE_HOOK, |
|
41
|
|
|
]; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Method used to fetch the type of the connection for an event. It can be |
|
45
|
|
|
* either a signal or a hook. |
|
46
|
|
|
* |
|
47
|
|
|
* @param MixedTypesResolver $resolver |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function getInstanceClassName(MixedTypesResolver $resolver) |
|
50
|
|
|
{ |
|
51
|
|
|
try { |
|
52
|
|
|
$connectionType = self::getConnectionType($resolver); |
|
53
|
|
|
$resolver->setObjectType(self::$allowedTypes[$connectionType]); |
|
54
|
|
|
} catch (NotizException $exception) { |
|
55
|
|
|
$error = new Error($exception->getMessage(), $exception->getCode()); |
|
56
|
|
|
$resolver->addError($error); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* The `type` property should be filled in the definition, with one of the |
|
62
|
|
|
* allowed values. If something is wrong, an error is sent to the resolver. |
|
63
|
|
|
* |
|
64
|
|
|
* @param MixedTypesResolver $resolver |
|
65
|
|
|
* @return string |
|
66
|
|
|
* |
|
67
|
|
|
* @throws EntryNotFoundException |
|
68
|
|
|
* @throws InvalidTypeException |
|
69
|
|
|
*/ |
|
70
|
|
|
protected static function getConnectionType(MixedTypesResolver $resolver): string |
|
71
|
|
|
{ |
|
72
|
|
|
$data = $resolver->getData(); |
|
73
|
|
|
$data = is_array($data) |
|
74
|
|
|
? $data |
|
75
|
|
|
: []; |
|
76
|
|
|
|
|
77
|
|
|
if (false === isset($data['type'])) { |
|
78
|
|
|
throw EntryNotFoundException::eventConnectionTypeMissing(array_keys(self::$allowedTypes)); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
$type = $data['type']; |
|
82
|
|
|
|
|
83
|
|
|
if (false === array_key_exists($type, self::$allowedTypes)) { |
|
84
|
|
|
throw InvalidTypeException::eventConnectionWrongType($type, array_keys(self::$allowedTypes)); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
return $type; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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