EventApplication.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. * 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. * @license https://www.opensource.org/licenses/mit-license.php MIT License
  13. */
  14. namespace TestApp\Http;
  15. use Cake\Console\CommandCollection;
  16. use Cake\Event\EventManagerInterface;
  17. use Cake\Http\BaseApplication;
  18. use Cake\Http\MiddlewareQueue;
  19. use TestApp\Command\DemoCommand;
  20. class EventApplication extends BaseApplication
  21. {
  22. public function events(EventManagerInterface $eventManager): EventManagerInterface
  23. {
  24. $eventManager->on('My.event', function (): void {
  25. });
  26. return $eventManager;
  27. }
  28. public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
  29. {
  30. return $middlewareQueue;
  31. }
  32. public function console(CommandCollection $commands): CommandCollection
  33. {
  34. return $commands->addMany(['ex' => DemoCommand::class]);
  35. }
  36. }