EventApplication.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. * Licensed under The MIT License
  6. * For full copyright and license information, please see the LICENSE.txt
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  10. * @link http://cakephp.org CakePHP(tm) Project
  11. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  12. */
  13. namespace TestApp\Http;
  14. use Cake\Event\EventManagerInterface;
  15. use Cake\Http\BaseApplication;
  16. use Psr\Http\Message\ResponseInterface;
  17. use Psr\Http\Message\ServerRequestInterface;
  18. use TestApp\Command\DemoCommand;
  19. class EventApplication extends BaseApplication
  20. {
  21. public function events(EventManagerInterface $eventManager)
  22. {
  23. $eventManager->on('My.event', function () {
  24. });
  25. return $eventManager;
  26. }
  27. public function middleware($middleware)
  28. {
  29. return $middleware;
  30. }
  31. public function console($commands)
  32. {
  33. return $commands->addMany(['ex' => DemoCommand::class]);
  34. }
  35. public function __invoke(ServerRequestInterface $req, ResponseInterface $res, $next)
  36. {
  37. return $res;
  38. }
  39. }