From 90a8cb30e648ae3dcf5fe60c540f31867548e9a7 Mon Sep 17 00:00:00 2001 From: Anton Grebnev Date: Mon, 4 Jun 2012 16:08:35 +0400 Subject: [PATCH] added getter and setter to Router to use error layout --- app/router/Router.php | 20 ++++++++++++++++++++ tests/app/router/RouterTest.php | 13 +++++++++++++ 2 files changed, 33 insertions(+) diff --git a/app/router/Router.php b/app/router/Router.php index 5eca53d..f79f588 100644 --- a/app/router/Router.php +++ b/app/router/Router.php @@ -18,6 +18,8 @@ class Router protected $default_layout = 'Default'; + protected $error_layout = 'Error'; + /** * @var Route */ @@ -51,6 +53,24 @@ class Router $this->default_layout = $layout; } + /** + * Sets the name of error page layout + * @param string $layout + */ + public function setErrorLayout($layout = 'Error') + { + $this->error_layout = $layout; + } + + /** + * Returns error layout name + * @return string Error layout name + */ + public function getErrorLayout() + { + return $this->error_layout . 'Layout'; + } + public function getRouteName() { return $this->route_name; diff --git a/tests/app/router/RouterTest.php b/tests/app/router/RouterTest.php index d2c831f..a91e4ae 100644 --- a/tests/app/router/RouterTest.php +++ b/tests/app/router/RouterTest.php @@ -106,4 +106,17 @@ class RouterTest extends PHPUnit_Framework_TestCase $this->assertTrue($router->routeIsExists($name)); $this->assertFalse($router->routeIsExists($name_is_not_exists)); } + + public function testGetDefaultErrorLayout() + { + $router = new Router(); + $this->assertSame('ErrorLayout', $router->getErrorLayout()); + } + + public function testSetErrorLayout() + { + $router = new Router(); + $router->setErrorLayout('CustomError'); + $this->assertSame('CustomErrorLayout', $router->getErrorLayout()); + } }