CakeErrorController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Error Handling Controller
  4. *
  5. * Controller used by ErrorHandler to render error views.
  6. *
  7. * PHP 5
  8. *
  9. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  10. * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  11. *
  12. * Licensed under The MIT License
  13. * Redistributions of files must retain the above copyright notice.
  14. *
  15. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  16. * @link http://cakephp.org CakePHP(tm) Project
  17. * @package Cake.Controller
  18. * @since CakePHP(tm) v 2.0
  19. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  20. */
  21. /**
  22. * Error Handling Controller
  23. *
  24. * Controller used by ErrorHandler to render error views.
  25. *
  26. * @package Cake.Controller
  27. */
  28. class CakeErrorController extends AppController {
  29. /**
  30. * Controller name
  31. *
  32. * @var string
  33. */
  34. public $name = 'CakeError';
  35. /**
  36. * Uses Property
  37. *
  38. * @var array
  39. */
  40. public $uses = array();
  41. /**
  42. * __construct
  43. *
  44. * @param CakeRequest $request
  45. * @param CakeResponse $response
  46. */
  47. public function __construct($request = null, $response = null) {
  48. parent::__construct($request, $response);
  49. if (
  50. count(Router::extensions()) &&
  51. !array_key_exists('RequestHandler', $this->components) &&
  52. !in_array('RequestHandler', $this->components, true)
  53. ) {
  54. $this->components[] = 'RequestHandler';
  55. }
  56. $this->constructClasses();
  57. if ($this->Components->enabled('Auth')) {
  58. $this->Components->disable('Auth');
  59. }
  60. if ($this->Components->enabled('Security')) {
  61. $this->Components->disable('Security');
  62. }
  63. $this->startupProcess();
  64. $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors'));
  65. }
  66. /**
  67. * Escapes the viewVars.
  68. *
  69. * @return void
  70. */
  71. public function beforeRender() {
  72. parent::beforeRender();
  73. foreach ($this->viewVars as $key => $value) {
  74. if (!is_object($value)) {
  75. $this->viewVars[$key] = h($value);
  76. }
  77. }
  78. }
  79. }