ApplicationWithPluginRoutes.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 3.6.6
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace TestApp;
  17. use Cake\Http\BaseApplication;
  18. use Cake\Http\MiddlewareQueue;
  19. use Cake\Routing\Middleware\RoutingMiddleware;
  20. use Cake\Routing\RouteBuilder;
  21. class ApplicationWithPluginRoutes extends BaseApplication
  22. {
  23. public function bootstrap(): void
  24. {
  25. parent::bootstrap();
  26. $this->addPlugin('TestPlugin');
  27. }
  28. public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
  29. {
  30. $middlewareQueue->add(new RoutingMiddleware($this));
  31. return $middlewareQueue;
  32. }
  33. /**
  34. * Routes hook, used for testing with RoutingMiddleware.
  35. */
  36. public function routes(RouteBuilder $routes): void
  37. {
  38. $routes->scope('/app', function (RouteBuilder $routes): void {
  39. $routes->connect('/articles', ['controller' => 'Articles']);
  40. });
  41. $routes->loadPlugin('TestPlugin');
  42. }
  43. }