Completed
Pull Request — master (#2)
by
unknown
05:39
created

Application::middleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 18
rs 10
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11
 * @link      https://cakephp.org CakePHP(tm) Project
12
 * @since     3.3.0
13
 * @license   https://opensource.org/licenses/mit-license.php MIT License
14
 */
15
namespace App;
16
17
use Cake\Core\Configure;
18
use Cake\Core\Exception\MissingPluginException;
19
use Cake\Error\Middleware\ErrorHandlerMiddleware;
20
use Cake\Http\BaseApplication;
21
use Cake\Routing\Middleware\AssetMiddleware;
22
use Cake\Routing\Middleware\RoutingMiddleware;
23
24
/**
25
 * Application setup class.
26
 *
27
 * This defines the bootstrapping logic and middleware layers you
28
 * want to use in your application.
29
 */
30
class Application extends BaseApplication
31
{
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function bootstrap()
36
    {
37
        // Call parent to load bootstrap from files.
38
        parent::bootstrap();
39
40
        if (PHP_SAPI === 'cli') {
41
            try {
42
                $this->addPlugin('Bake');
43
            } catch (MissingPluginException $e) {
44
                unset($e);
45
            }
46
            $this->addPlugin('Migrations');
47
        }
48
49
        if (Configure::read('debug')) {
50
            $this->addPlugin(\DebugKit\Plugin::class, ['bootstrap' => true]);
0 ignored issues
show
Bug introduced by
The type DebugKit\Plugin 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...
51
        }
52
53
		$this->addPlugin(\VatNumberCheck\Plugin::class, ['routes' => true, 'bootstrap' => false]);
54
    }
55
56
    /**
57
     * Setup the middleware queue your application will use.
58
     *
59
     * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
60
     * @return \Cake\Http\MiddlewareQueue The updated middleware queue.
61
     */
62
    public function middleware($middlewareQueue)
63
    {
64
        // @phan-suppress-next-line PhanUndeclaredFunctionInCallable
65
        $middlewareQueue
66
            // Catch any exceptions in the lower layers,
67
            // and make an error page/response
68
            ->add(ErrorHandlerMiddleware::class)
69
70
            // Handle plugin/theme assets like CakePHP normally does.
71
            ->add(AssetMiddleware::class)
72
73
            // Add routing middleware.
74
            // Routes collection cache enabled by default, to disable route caching
75
            // pass null as cacheConfig, example: `new RoutingMiddleware($this)`
76
            // you might want to disable this cache in case your routing is extremely simple
77
            ->add(new RoutingMiddleware($this, '_cake_routes_'));
78
79
        return $middlewareQueue;
80
    }
81
}
82