Application::middleware()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/**
3
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4
 * Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
11
 * @link      http://cakephp.org CakePHP(tm) Project
12
 * @since     3.3.0
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
14
 */
15
namespace App;
16
17
use Cake\Core\Configure;
18
use Cake\Error\Middleware\ErrorHandlerMiddleware;
19
use Cake\Http\BaseApplication;
20
use Cake\I18n\Middleware\LocaleSelectorMiddleware;
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
     * Setup the middleware your application will use.
34
     *
35
     * @param \Cake\Http\MiddlewareQueue $middleware The middleware queue to setup.
36
     * @return \Cake\Http\MiddlewareQueue The updated middleware.
37
     */
38
    public function middleware($middleware)
39
    {
40
        $middleware
41
            // Handle plugin/theme assets like CakePHP normally does.
42
            ->add(AssetMiddleware::class)
43
44
            // Apply routing
45
            ->add(RoutingMiddleware::class)
46
47
            // Handle the language switching from the Accept-Language header
48
            ->add(new LocaleSelectorMiddleware(['locales' => ['en_US', 'en', 'fr_FR', 'fr']]));
49
50
        return $middleware;
51
    }
52
}
53