1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Gewaer\Providers; |
6
|
|
|
|
7
|
|
|
use function Canvas\Core\appPath; |
8
|
|
|
use Gewaer\Middleware\NotFoundMiddleware; |
9
|
|
|
use Gewaer\Middleware\AuthenticationMiddleware; |
10
|
|
|
use Gewaer\Middleware\TokenValidationMiddleware; |
11
|
|
|
use Gewaer\Middleware\AclMiddleware; |
12
|
|
|
use Canvas\Middleware\ThrottleMiddleware; |
|
|
|
|
13
|
|
|
use Phalcon\Mvc\Micro; |
14
|
|
|
use Canvas\Providers\RouterProvider as CanvasRouterProvider; |
15
|
|
|
|
16
|
|
|
class RouterProvider extends CanvasRouterProvider |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Attaches the routes to the application; lazy loaded. |
20
|
|
|
* |
21
|
|
|
* @param Micro $application |
22
|
73 |
|
*/ |
23
|
|
|
protected function attachRoutes(Micro $application) |
24
|
73 |
|
{ |
25
|
|
|
$routes = $this->getRoutes(); |
26
|
73 |
|
|
27
|
73 |
|
foreach ($routes as $route) { |
28
|
|
|
include $route; |
29
|
73 |
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Returns the array for the middleware with the action to attach. |
34
|
|
|
* |
35
|
|
|
* @return array |
36
|
73 |
|
*/ |
37
|
|
|
protected function getMiddleware(): array |
38
|
|
|
{ |
39
|
73 |
|
if (!defined('API_TESTS')) { |
40
|
|
|
return [ |
41
|
|
|
ThrottleMiddleware::class => 'before', |
42
|
|
|
TokenValidationMiddleware::class => 'before', |
43
|
|
|
NotFoundMiddleware::class => 'before', |
44
|
|
|
AuthenticationMiddleware::class => 'before', |
45
|
|
|
AclMiddleware::class => 'before', |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
return [ |
50
|
|
|
TokenValidationMiddleware::class => 'before', |
51
|
73 |
|
NotFoundMiddleware::class => 'before', |
52
|
|
|
AuthenticationMiddleware::class => 'before', |
53
|
73 |
|
AclMiddleware::class => 'before', |
54
|
73 |
|
]; |
55
|
|
|
|
56
|
|
|
} |
|
|
|
|
57
|
73 |
|
|
58
|
73 |
|
/** |
59
|
|
|
* Returns the array for all the routes on this system. |
60
|
|
|
* |
61
|
73 |
|
* @return array |
62
|
|
|
*/ |
63
|
|
|
protected function getRoutes(): array |
64
|
|
|
{ |
65
|
|
|
$path = appPath('api/routes'); |
66
|
|
|
$canvsaPath = getenv('CANVAS_CORE_PATH'); |
67
|
|
|
|
68
|
|
|
$routes = [ |
69
|
|
|
'api' => $path . '/api.php', |
70
|
|
|
'canvas' => $canvsaPath. '/routes/api.php' |
71
|
|
|
]; |
72
|
|
|
|
73
|
|
|
return $routes; |
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