Completed
Push — master ( 7c757d...667317 )
by William
02:47
created

Application::bootstrap()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
ccs 7
cts 7
cp 1
cc 3
nc 4
nop 0
crap 3
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
     * @return void
35
     */
36 20
    public function bootstrap()
37
    {
38
        // Call parent to load bootstrap from files.
39 20
        parent::bootstrap();
40
41 20
        if (PHP_SAPI === 'cli') {
42 20
            $this->bootstrapCli();
43
        }
44
45
        /*
46
         * Only try to load DebugKit in development mode
47
         * Debug Kit should not be installed on a production system
48
         */
49 20
        if (Configure::read('debug')) {
50 20
            $this->addPlugin(\DebugKit\Plugin::class);
51
        }
52
53
        // Load more plugins here
54 20
    }
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 20
    public function middleware($middlewareQueue)
63
    {
64
        $middlewareQueue
65
            // Catch any exceptions in the lower layers,
66
            // and make an error page/response
67 20
            ->add(new ErrorHandlerMiddleware(null, Configure::read('Error')))
68
69
            // Handle plugin/theme assets like CakePHP normally does.
70 20
            ->add(new AssetMiddleware([
71 20
                'cacheTime' => Configure::read('Asset.cacheTime'),
72
            ]))
73
74
            // Add routing middleware.
75
            // If you have a large number of routes connected, turning on routes
76
            // caching in production could improve performance. For that when
77
            // creating the middleware instance specify the cache config name by
78
            // using it's second constructor argument:
79
            // `new RoutingMiddleware($this, '_cake_routes_')`
80 20
            ->add(new RoutingMiddleware($this));
81
82 20
        return $middlewareQueue;
83
    }
84
85
    /**
86
     * @return void
87
     */
88 20
    protected function bootstrapCli()
89
    {
90
        try {
91 20
            $this->addPlugin('Bake');
92
        } catch (MissingPluginException $e) {// phpcs:ignore
0 ignored issues
show
Bug introduced by
The class Cake\Core\Exception\MissingPluginException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
93
            // Do not halt if the plugin is missing
94
        }
95
96 20
        $this->addPlugin('Migrations');
97
98
        // Load more plugins here
99 20
    }
100
}
101