modified FrontController to get error layout from Router
This commit is contained in:
@ -41,7 +41,9 @@ class FrontController
|
|||||||
/**
|
/**
|
||||||
* Refuse cloning
|
* Refuse cloning
|
||||||
*/
|
*/
|
||||||
private function __clone(){}
|
private function __clone()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return FrontController
|
* @return FrontController
|
||||||
@ -126,14 +128,20 @@ class FrontController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
} catch(Exception $e) {
|
} catch (Exception $e) {
|
||||||
if (DEBUG == true) {
|
if (DEBUG == true) {
|
||||||
if (!headers_sent()) {
|
if (!headers_sent()) {
|
||||||
header('HTTP/1.0 500 Internal Server Error');
|
header('HTTP/1.0 500 Internal Server Error');
|
||||||
}
|
}
|
||||||
return ErrorHandler::showDebug($e);
|
return ErrorHandler::showDebug($e);
|
||||||
}
|
}
|
||||||
$layout = new ErrorLayout();
|
$layout_class = $this->getRouter()->getErrorLayout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var ErrorLayout $layout
|
||||||
|
*/
|
||||||
|
$layout = new $layout_class();
|
||||||
|
$layout->setException($e);
|
||||||
return $layout->fetch(new ErrorAction($e));
|
return $layout->fetch(new ErrorAction($e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->getMock('View');
|
$this->getMock('View');
|
||||||
}
|
}
|
||||||
if (!class_exists('ErrorLayout')) {
|
if (!class_exists('ErrorLayout')) {
|
||||||
$this->getMock('ErrorLayout', array('fetch'), array(), 'ErrorLayoutMock');
|
$this->getMock('ErrorLayout', array('fetch', 'setException'), array(), 'ErrorLayoutMock');
|
||||||
}
|
}
|
||||||
if (!class_exists('ErrorActionMock')) {
|
if (!class_exists('ErrorActionMock')) {
|
||||||
$this->getMock('ErrorAction', array(), array(), 'ErrorActionMock', false);
|
$this->getMock('ErrorAction', array(), array(), 'ErrorActionMock', false);
|
||||||
@ -190,7 +190,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$router = $controller->getRouter();
|
$router = $controller->getRouter();
|
||||||
$router->add('user', 'user/account/:id', 'user');
|
$router->add('user', 'user/account/:id', 'user');
|
||||||
$result = $controller->execute();
|
$result = $controller->execute();
|
||||||
$this->assertEmpty($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @runInSeparateProcess
|
* @runInSeparateProcess
|
||||||
@ -205,7 +205,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
$router = $controller->getRouter();
|
$router = $controller->getRouter();
|
||||||
$router->add('user', 'user/account/:id', 'NewAjax');
|
$router->add('user', 'user/account/:id', 'NewAjax');
|
||||||
$result = $controller->execute();
|
$result = $controller->execute();
|
||||||
$this->assertEmpty($result);
|
$this->assertNull($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setConstants($val = false)
|
private function setConstants($val = false)
|
||||||
@ -227,8 +227,6 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
|
|||||||
return 'PHPViewMock';
|
return 'PHPViewMock';
|
||||||
case 'DefaultLayout':
|
case 'DefaultLayout':
|
||||||
return 'DefaultLayoutMock';
|
return 'DefaultLayoutMock';
|
||||||
case 'userAction':
|
|
||||||
return 'userAction';
|
|
||||||
case 'ErrorAction':
|
case 'ErrorAction':
|
||||||
return 'ErrorActionMock';
|
return 'ErrorActionMock';
|
||||||
case 'ErrorLayout':
|
case 'ErrorLayout':
|
||||||
|
Reference in New Issue
Block a user