1
|
|
|
<?php |
2
|
|
|
/*************************************************************** |
3
|
|
|
* Copyright notice |
4
|
|
|
* |
5
|
|
|
* (c) 2009 AOE media ([email protected]) |
6
|
|
|
* All rights reserved |
7
|
|
|
* |
8
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
9
|
|
|
* free software; you can redistribute it and/or modify |
10
|
|
|
* it under the terms of the GNU General Public License as published by |
11
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
12
|
|
|
* (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* The GNU General Public License can be found at |
15
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
16
|
|
|
* |
17
|
|
|
* This script is distributed in the hope that it will be useful, |
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20
|
|
|
* GNU General Public License for more details. |
21
|
|
|
* |
22
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
23
|
|
|
***************************************************************/ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The event dispatcher can be used to register an observer for a |
27
|
|
|
* given event. The observer needs to implement the inferface |
28
|
|
|
* tx_crawler_domain_events_observer |
29
|
|
|
* |
30
|
|
|
* each observer needs to be registered as a TYPO3 Hook. |
31
|
|
|
* Example: |
32
|
|
|
* |
33
|
|
|
* $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'][] = 'EXT:aoe_xyz/domain/events/class.tx_xyz_domain_events_crawler.php:tx_xyz_domain_events_crawler'; |
34
|
|
|
* |
35
|
|
|
* in the registerObservers the observer can register itself for events: |
36
|
|
|
* |
37
|
|
|
* public function registerObservers(tx_crawler_domain_events_dispatcher $dispatcher) { |
38
|
|
|
* $dispatcher->addObserver($this,'addUrl','urlAddedToQueue'); |
39
|
|
|
* $dispatcher->addObserver($this,'duplicateUrlInQueue','duplicateUrlInQueue'); |
40
|
|
|
* $dispatcher->addObserver($this,'urlCrawled','urlCrawled'); |
41
|
|
|
* $dispatcher->addObserver($this,'invokeQueueChange','invokeQueueChange'); |
42
|
|
|
* $dispatcher->addObserver($this,'contentChange','contentChange'); |
43
|
|
|
* } |
44
|
|
|
* |
45
|
|
|
* The dispatcher is a singleton. The instance can be retrieved by: |
46
|
|
|
* |
47
|
|
|
* tx_crawler_domain_events_dispatcher::getInstance(); |
48
|
|
|
* |
49
|
|
|
* Events can be posted by tx_crawler_domain_events_dispatcher::getInstance()->post('myEvent','eventGroup', array('foo' => 'bar')); |
50
|
|
|
*/ |
51
|
|
|
class tx_crawler_domain_events_dispatcher |
52
|
|
|
{ |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var array of tx_crawler_domain_events_observer objects; |
56
|
|
|
*/ |
57
|
|
|
protected $observers; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var tx_crawler_domain_events_dispatcher |
61
|
|
|
*/ |
62
|
|
|
protected static $instance; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* The __constructor is private because the dispatcher is a singleton |
66
|
|
|
* |
67
|
|
|
* @param void |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
protected function __construct() |
71
|
|
|
{ |
72
|
|
|
$this->observers = []; |
73
|
|
|
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'])) { |
74
|
|
|
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'] as $classRef) { |
75
|
|
|
$hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
|
|
|
76
|
|
|
if (method_exists($hookObj, 'registerObservers')) { |
77
|
|
|
$hookObj->registerObservers($this); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Returns all registered eventtypes. |
85
|
|
|
* |
86
|
|
|
* @param void |
87
|
|
|
* @return array array with registered events. |
88
|
|
|
*/ |
89
|
|
|
protected function getEvents() |
90
|
|
|
{ |
91
|
|
|
return array_keys($this->observers); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* This method can be used to add an observer for an event to the dispatcher |
96
|
|
|
* |
97
|
|
|
* @param tx_crawler_domain_events_observer $observer_object |
98
|
|
|
* @param string $observer_method |
99
|
|
|
* @param string $event |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
public function addObserver(tx_crawler_domain_events_observer $observer_object, $observer_method, $event) |
103
|
|
|
{ |
104
|
|
|
$this->observers[$event][] = ['object' => $observer_object, 'method' => $observer_method]; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Enables checking whether a certain event is observed by anyone |
109
|
|
|
* |
110
|
|
|
* @param string $event |
111
|
|
|
* @return boolean |
112
|
|
|
*/ |
113
|
|
|
public function hasObserver($event) |
114
|
|
|
{ |
115
|
|
|
return count($this->observers[$event]) > 0; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* This method should be used to post a event to the dispatcher. Each |
120
|
|
|
* registered observer will be notified about the event. |
121
|
|
|
* |
122
|
|
|
* @param string $event |
123
|
|
|
* @param string $group |
124
|
|
|
* @param mixed $attachedData |
125
|
|
|
* @return void |
126
|
|
|
*/ |
127
|
|
|
public function post($event, $group, $attachedData) |
128
|
|
|
{ |
129
|
|
|
if (is_array($this->observers[$event])) { |
130
|
|
|
foreach ($this->observers[$event] as $eventObserver) { |
131
|
|
|
call_user_func([$eventObserver['object'],$eventObserver['method']], $event, $group, $attachedData); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Returns the instance of the dispatcher singleton |
138
|
|
|
* |
139
|
|
|
* @param void |
140
|
|
|
* @return tx_crawler_domain_events_dispatcher |
141
|
|
|
*/ |
142
|
|
|
public static function getInstance() |
143
|
|
|
{ |
144
|
|
|
if (!self::$instance instanceof tx_crawler_domain_events_dispatcher) { |
145
|
|
|
$dispatcher = new tx_crawler_domain_events_dispatcher(); |
146
|
|
|
self::$instance = $dispatcher; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return self::$instance; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
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