|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
+------------------------------------------------------------------------+ |
|
5
|
|
|
| Phalcon Framework | |
|
6
|
|
|
+------------------------------------------------------------------------+ |
|
7
|
|
|
| Copyright (c) 2011-2017 Phalcon Team (https://www.phalconphp.com) | |
|
8
|
|
|
+------------------------------------------------------------------------+ |
|
9
|
|
|
| This source file is subject to the New BSD License that is bundled | |
|
10
|
|
|
| with this package in the file LICENSE.txt. | |
|
11
|
|
|
| | |
|
12
|
|
|
| If you did not receive a copy of the license and are unable to | |
|
13
|
|
|
| obtain it through the world-wide-web, please send an email | |
|
14
|
|
|
| to [email protected] so we can send you a copy immediately. | |
|
15
|
|
|
+------------------------------------------------------------------------+ |
|
16
|
|
|
| Authors: Sergii Svyrydenko <[email protected]> | |
|
17
|
|
|
+------------------------------------------------------------------------+ |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Canvas\Traits; |
|
21
|
|
|
|
|
22
|
|
|
use Phalcon\Di; |
|
23
|
|
|
use Phalcon\Events\ManagerInterface as EventsManager; |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Phalcon\Traits\EventManagerAwareTrait |
|
27
|
|
|
* |
|
28
|
|
|
* Trait for event processing |
|
29
|
|
|
* |
|
30
|
|
|
* @package Phalcon\Traits |
|
31
|
|
|
*/ |
|
32
|
|
|
|
|
33
|
|
|
trait EventManagerAwareTrait |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var EventsManager |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $eventsManager = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* set event manager |
|
42
|
|
|
* |
|
43
|
|
|
* @param EventsManager $eventsManager |
|
44
|
|
|
*/ |
|
45
|
|
|
public function setEventsManager(EventsManager $manager) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->eventsManager = $manager; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* return event manager |
|
52
|
|
|
* |
|
53
|
|
|
* @return EventsManager | null |
|
54
|
|
|
*/ |
|
55
|
|
|
public function getEventsManager() |
|
56
|
|
|
{ |
|
57
|
|
|
$di = Di::getDefault(); |
|
58
|
|
|
|
|
59
|
|
|
if (!empty($this->eventsManager)) { |
|
60
|
|
|
$manager = $this->eventsManager; |
|
61
|
|
|
} elseif ($di->has('eventsManager')) { |
|
62
|
|
|
$manager = $di->get('eventsManager'); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if (isset($manager) && $manager instanceof EventsManager) { |
|
66
|
|
|
return $manager; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return null; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Checking if event manager is defined - fire event |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $event |
|
76
|
|
|
* @param object $source |
|
77
|
|
|
* @param mixed $data |
|
78
|
|
|
* @param boolean $cancelable |
|
79
|
|
|
* |
|
80
|
|
|
*/ |
|
81
|
|
|
public function fire($event, $source, $data = null, $cancelable = true) |
|
82
|
|
|
{ |
|
83
|
|
|
if ($manager = $this->getEventsManager()) { |
|
84
|
|
|
$manager->fire($event, $source, $data, $cancelable); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
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