ErrorController.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. *
  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. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 2.0.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Controller;
  16. use Cake\Event\Event;
  17. use Cake\Routing\Router;
  18. /**
  19. * Error Handling Controller
  20. *
  21. * Controller used by ErrorHandler to render error views.
  22. */
  23. class ErrorController extends Controller
  24. {
  25. /**
  26. * Constructor
  27. *
  28. * @param \Cake\Network\Request|null $request Request instance.
  29. * @param \Cake\Network\Response|null $response Response instance.
  30. */
  31. public function __construct($request = null, $response = null)
  32. {
  33. parent::__construct($request, $response);
  34. if (count(Router::extensions()) &&
  35. !isset($this->RequestHandler)
  36. ) {
  37. $this->loadComponent('RequestHandler');
  38. }
  39. $eventManager = $this->eventManager();
  40. if (isset($this->Auth)) {
  41. $eventManager->off($this->Auth);
  42. }
  43. if (isset($this->Security)) {
  44. $eventManager->off($this->Security);
  45. }
  46. }
  47. /**
  48. * beforeRender callback.
  49. *
  50. * @param \Cake\Event\Event $event Event.
  51. * @return void
  52. */
  53. public function beforeRender(Event $event)
  54. {
  55. $this->viewBuilder()->templatePath('Error');
  56. }
  57. }