-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helpers in custom CakeErrorController are lost
Since many exceptions do not have its own 'template' file, customized APP/Controller/CakeErrorController with its own list of helpers could be ignored. This happens becase ExceptionRenderer is forced to to use _outputMessageSafe when a template is missing. This causes Controller::$helpers to be reset with default values.
- Loading branch information
Showing
6 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib/Cake/Test/test_app/Controller/TestAppsErrorController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
App::uses('CakeErrorController', 'Controller'); | ||
|
||
class TestAppsErrorController extends CakeErrorController { | ||
|
||
public $helpers = array( | ||
'Html', | ||
'Session', | ||
'Form', | ||
'Banana', | ||
); | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
lib/Cake/Test/test_app/Error/TestAppsExceptionRenderer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
class TestAppsExceptionRenderer extends ExceptionRenderer { | ||
|
||
protected function _getController($exception) { | ||
App::uses('TestAppsErrorController', 'Controller'); | ||
if (!$request = Router::getRequest(true)) { | ||
$request = new CakeRequest(); | ||
} | ||
$response = new CakeResponse(array('charset' => Configure::read('App.encoding'))); | ||
try { | ||
$controller = new TestAppsErrorController($request, $response); | ||
$controller->layout = 'banana'; | ||
} catch (Exception $e) { | ||
$controller = new Controller($request, $response); | ||
$controller->viewPath = 'Errors'; | ||
} | ||
return $controller; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<body> | ||
<?php | ||
echo $this->Banana->peel(); | ||
?> | ||
</body> |