Failed Conditions
Branch master (e37483)
by Maximo
06:09
created

MiddlewareProvider::attachMiddleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Providers;
6
7
use Canvas\Middleware\NotFoundMiddleware;
8
use Baka\Router\Providers\MiddlewareProvider as BakaMiddlewareProvider;
9
use Canvas\Middleware\AuthenticationMiddleware;
10
use Canvas\Middleware\AclMiddleware;
11
use Phalcon\Mvc\Micro;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\Micro was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Phalcon\Events\Manager;
0 ignored issues
show
Bug introduced by
The type Phalcon\Events\Manager was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
14
class MiddlewareProvider extends BakaMiddlewareProvider
15
{
16
    protected $canvasGlobalMiddlewares = [
17
        // Before the handler has been executed
18
        NotFoundMiddleware::class => 'before',
19
    ];
20
21
    /**
22
     * This are the routes you have access to via the Baka routes components.
23
     *
24
     * This follows the order you specify on this array so
25
     *  - Token will run before Auth
26
     *
27
     * @var array
28
     */
29
    protected $canvasRouteMiddlewares = [
30
        'auth.jwt' => AuthenticationMiddleware::class,
31
        'auth.acl' => AclMiddleware::class,
32
    ];
33
34
    /**
35
     * Attaches the middleware to the application.
36
     *
37
     * @param Micro   $application
38
     * @param Manager $eventsManager
39
     */
40
    protected function attachMiddleware(Micro $application, Manager $eventsManager)
41
    {
42
        /**
43
         * Merge canvas Middleware with the app middleware.
44
         */
45
        $this->globalMiddlewares = array_merge($this->globalMiddlewares, $this->canvasGlobalMiddlewares);
46
        $this->routeMiddlewares = array_merge($this->routeMiddlewares, $this->canvasRouteMiddlewares);
47
48
        parent::attachMiddleware($application, $eventsManager);
49
    }
50
}
51