TestHttpKernel.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Components\HttpKernel;
  11. use Symfony\Components\HttpKernel\HttpKernel;
  12. use Symfony\Components\HttpKernel\Request;
  13. use Symfony\Components\HttpKernel\Response;
  14. use Symfony\Components\EventDispatcher\EventDispatcher;
  15. use Symfony\Components\EventDispatcher\Event;
  16. class TestHttpKernel extends HttpKernel
  17. {
  18. public function __construct()
  19. {
  20. $this->dispatcher = new EventDispatcher();
  21. $this->dispatcher->connect('core.load_controller', array($this, 'loadController'));
  22. }
  23. public function loadController(Event $event)
  24. {
  25. $event->setReturnValue(array(array($this, 'callController'), array($event['request'])));
  26. return true;
  27. }
  28. public function callController(Request $request)
  29. {
  30. return new Response('Request: '.$request->getRequestUri());
  31. }
  32. }