Plugin::middleware()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Sluggable;
5
6
use Cake\Core\BasePlugin;
7
use Cake\Core\PluginApplicationInterface;
8
use Cake\Http\MiddlewareQueue;
9
use Cake\Routing\RouteBuilder;
10
11
/**
12
 * Plugin for Sluggable
13
 */
14
class Plugin extends BasePlugin
15
{
16
    /**
17
     * Load all the plugin configuration and bootstrap logic.
18
     *
19
     * The host application is provided as an argument. This allows you to load
20
     * additional plugin dependencies, or attach events.
21
     *
22
     * @param \Cake\Core\PluginApplicationInterface $app The host application
23
     * @return void
24
     */
25
    public function bootstrap(PluginApplicationInterface $app): void
26
    {
27
    }
28
29
    /**
30
     * Add routes for the plugin.
31
     *
32
     * If your plugin has many routes and you would like to isolate them into a separate file,
33
     * you can create `$plugin/config/routes.php` and delete this method.
34
     *
35
     * @param \Cake\Routing\RouteBuilder $routes The route builder to update.
36
     * @return void
37
     */
38
    public function routes(RouteBuilder $routes): void
39
    {
40
        $routes->plugin(
41
            'Sluggable',
42
            ['path' => '/sluggable'],
43
            function (RouteBuilder $builder) {
44
                // Add custom routes here
45
46
                $builder->fallbacks();
47
            }
48
        );
49
        parent::routes($routes);
50
    }
51
52
    /**
53
     * Add middleware for the plugin.
54
     *
55
     * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to update.
56
     * @return \Cake\Http\MiddlewareQueue
57
     */
58
    public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
59
    {
60
        // Add your middlewares here
61
62
        return $middlewareQueue;
63
    }
64
}
65