|
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\Event\Service; |
|
19
|
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; |
|
21
|
|
|
use CuyZ\Notiz\Core\Event\Event; |
|
22
|
|
|
use CuyZ\Notiz\Core\Exception\ClassNotFoundException; |
|
23
|
|
|
use CuyZ\Notiz\Core\Exception\InvalidClassException; |
|
24
|
|
|
use CuyZ\Notiz\Core\Notification\Notification; |
|
25
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
26
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
class EventFactory implements SingletonInterface |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* @var EventRegistry |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $eventRegistry; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ObjectManager |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $objectManager; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param EventRegistry $eventRegistry |
|
42
|
|
|
* @param ObjectManager $objectManager |
|
43
|
|
|
*/ |
|
44
|
|
|
public function __construct(EventRegistry $eventRegistry, ObjectManager $objectManager) |
|
45
|
|
|
{ |
|
46
|
|
|
$this->eventRegistry = $eventRegistry; |
|
47
|
|
|
$this->objectManager = $objectManager; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param EventDefinition $eventDefinition |
|
52
|
|
|
* @param Notification $notification |
|
53
|
|
|
* @return Event |
|
54
|
|
|
* |
|
55
|
|
|
* @throws ClassNotFoundException |
|
56
|
|
|
* @throws InvalidClassException |
|
57
|
|
|
*/ |
|
58
|
|
|
public function create(EventDefinition $eventDefinition, Notification $notification): Event |
|
59
|
|
|
{ |
|
60
|
|
|
$className = $eventDefinition->getClassName(); |
|
61
|
|
|
|
|
62
|
|
|
if (!class_exists($className)) { |
|
63
|
|
|
throw ClassNotFoundException::eventClassNotFound($className); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if (!in_array(Event::class, class_implements($className))) { |
|
67
|
|
|
throw InvalidClassException::eventHasMissingInterface($className); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** @var Event $event */ |
|
71
|
|
|
$event = $this->objectManager->get($className, $eventDefinition, $notification); |
|
72
|
|
|
|
|
73
|
|
|
return $event; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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