|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace JsonApiException; |
| 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 JsonApiException |
| 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 | + 'JsonApiException', |
| 42 | + ['path' => '/json-api-exception'], |
| 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 $middleware 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 | +} |
0 commit comments