1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhalconExt\Cli; |
4
|
|
|
|
5
|
|
|
use Ahc\Cli\Helper\OutputHelper; |
|
|
|
|
6
|
|
|
use Ahc\Cli\Input\Command; |
|
|
|
|
7
|
|
|
use Ahc\Cli\Output\Writer; |
|
|
|
|
8
|
|
|
use Phalcon\Cli\Console; |
|
|
|
|
9
|
|
|
|
10
|
|
|
trait MiddlewareTrait |
11
|
|
|
{ |
12
|
|
|
protected $middlewares = [ |
13
|
|
|
Middleware\Factory::class, |
14
|
|
|
]; |
15
|
|
|
|
16
|
|
|
protected function bindEvents(Console $console) |
17
|
|
|
{ |
18
|
|
|
$evm = $this->di('eventsManager'); |
|
|
|
|
19
|
|
|
|
20
|
|
|
$evm->attach('dispatch', $console); |
21
|
|
|
$console->setEventsManager($evm); |
22
|
|
|
|
23
|
|
|
$this->di('dispatcher')->setEventsManager($evm); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function middleware(string $class): self |
27
|
|
|
{ |
28
|
|
|
$this->middlewares[] = $class; |
29
|
|
|
|
30
|
|
|
return $this; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function middlewares(): array |
34
|
|
|
{ |
35
|
|
|
return $this->middlewares; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function beforeExecuteRoute(): bool |
39
|
|
|
{ |
40
|
|
|
return $this->relay('before'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function afterExecuteRoute(): bool |
44
|
|
|
{ |
45
|
|
|
return $this->relay('after'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected function relay(string $event): bool |
49
|
|
|
{ |
50
|
|
|
foreach ($this->middlewares as $middleware) { |
51
|
|
|
if (!$this->call($event, $middleware)) { |
52
|
|
|
return false; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
return true; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
protected function call(string $event, $middleware): bool |
60
|
|
|
{ |
61
|
|
|
if (\is_string($middleware)) { |
62
|
|
|
$middleware = $this->di($middleware); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (!\method_exists($middleware, $event)) { |
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $middleware->$event($this->di('console')); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
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