Skip to content

Commit

Permalink
Support not adding the Handler suffix to a classname for internal h…
Browse files Browse the repository at this point in the history
…andlers
  • Loading branch information
josegonzalez committed Dec 26, 2015
1 parent 4976168 commit 9e0103f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/Cake/ConsoleErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ public function handle($exception)
{
$handlers = (array)Configure::read('Error.config.handlers');
foreach ($handlers as $handler => $config) {
if (!class_exists($handler)) {
$handler = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
$handlerClass = $handler;
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
}
if (!class_exists($handler)) {
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
}
if (!class_exists($handlerClass)) {
continue;
}
$instance = new $handler((array)$config);
$instance = new $handlerClass((array)$config);
$instance->handle($exception);
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/Cake/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ public function handle($exception)
{
$handlers = (array)Configure::read('Error.config.handlers');
foreach ($handlers as $handler => $config) {
if (!class_exists($handler)) {
$handler = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
$handlerClass = $handler;
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
}
if (!class_exists($handler)) {
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
}
if (!class_exists($handlerClass)) {
continue;
}
$instance = new $handler((array)$config);
$instance = new $handlerClass((array)$config);
$instance->handle($exception);
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@ public function handle(Exception $exception)
{
$handlers = (array)$this->config('handlers');
foreach ($handlers as $handler => $config) {
if (!class_exists($handler)) {
$handler = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
$handlerClass = $handler;
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler;
}
if (!class_exists($handler)) {
if (!class_exists($handlerClass)) {
$handlerClass = 'Josegonzalez\ErrorHandlers\Handler\\' . $handler . 'Handler';
}
if (!class_exists($handlerClass)) {
continue;
}
$instance = new $handler((array)$config);
$instance = new $handlerClass((array)$config);
$instance->handle($exception);
}
return false;
Expand Down

0 comments on commit 9e0103f

Please sign in to comment.