|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Canvas\Providers; |
|
4
|
|
|
|
|
5
|
|
|
use Phalcon\Di\ServiceProviderInterface; |
|
|
|
|
|
|
6
|
|
|
use Phalcon\DiInterface; |
|
|
|
|
|
|
7
|
|
|
use Canvas\Listener\Subscription; |
|
8
|
|
|
use Canvas\EventsManager; |
|
9
|
|
|
use Canvas\Listener\User; |
|
10
|
|
|
use Canvas\Listener\Notification; |
|
11
|
|
|
use Canvas\Listener\Company; |
|
12
|
|
|
|
|
13
|
|
|
class EventsManagerProvider implements ServiceProviderInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* List of the listeners use by the app. |
|
17
|
|
|
* |
|
18
|
|
|
* [ |
|
19
|
|
|
* 'eventName' => 'className' |
|
20
|
|
|
* ]; |
|
21
|
|
|
* |
|
22
|
|
|
* @var array |
|
23
|
|
|
*/ |
|
24
|
|
|
protected $listeners = [ |
|
25
|
|
|
]; |
|
26
|
|
|
|
|
27
|
|
|
protected $canvasListeners = [ |
|
28
|
|
|
'subscription' => Subscription::class, |
|
29
|
|
|
'user' => User::class, |
|
30
|
|
|
'company' => Company::class, |
|
31
|
|
|
'notification' => Notification::class, |
|
32
|
|
|
]; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param DiInterface $container |
|
36
|
|
|
*/ |
|
37
|
|
|
public function register(DiInterface $container) |
|
38
|
|
|
{ |
|
39
|
|
|
$container->setShared( |
|
40
|
|
|
'events', |
|
41
|
|
|
function () { |
|
42
|
|
|
$eventsManager = new EventsManager(); |
|
43
|
|
|
|
|
44
|
|
|
return $eventsManager; |
|
45
|
|
|
} |
|
46
|
|
|
); |
|
47
|
|
|
|
|
48
|
|
|
$this->attachEvents($container, $this->listeners); |
|
49
|
|
|
$this->attachEvents($container, $this->canvasListeners); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* given the DI attach the list of containers. |
|
54
|
|
|
* |
|
55
|
|
|
* @param DiInterface $container |
|
56
|
|
|
* @param array $listeners |
|
57
|
|
|
* @return void |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function attachEvents(DiInterface $container, array $listeners): bool |
|
60
|
|
|
{ |
|
61
|
|
|
if (empty($listeners)) { |
|
62
|
|
|
return false; |
|
|
|
|
|
|
63
|
|
|
} |
|
64
|
|
|
$eventsManager = $container->get('eventsManager'); |
|
65
|
|
|
|
|
66
|
|
|
//navigate the list of listener and create the events |
|
67
|
|
|
foreach ($listeners as $key => $listen) { |
|
68
|
|
|
//create the events given the key |
|
69
|
|
|
$eventsManager->attach( |
|
70
|
|
|
$key, |
|
71
|
|
|
new $listen() |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return true; |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
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