From 1e413db8c967005fb767e118dfc1e0050755d381 Mon Sep 17 00:00:00 2001 From: tmont Date: Sat, 18 Oct 2008 19:55:18 +0000 Subject: [PATCH] updated controller/view factories; renamed PanaceaPageController to PanaceaDefaultController --- src/bootstrap.php | 2 +- src/lib/PanaceaControllerFactory.php | 16 ++++++++++++---- src/lib/PanaceaPageController.php | 8 ++++---- src/lib/PanaceaViewFactory.php | 4 ---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/bootstrap.php b/src/bootstrap.php index e957fd5..b82276d 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -24,7 +24,7 @@ $file = ''; switch ($className) { case 'PanaceaControllerFactory': - case 'PanaceaPageController': + case 'PanaceaDefaultController': case 'PanaceaViewFactory': $file = "$path/lib/$className.php"; break; diff --git a/src/lib/PanaceaControllerFactory.php b/src/lib/PanaceaControllerFactory.php index 0b31175..e539c46 100644 --- a/src/lib/PanaceaControllerFactory.php +++ b/src/lib/PanaceaControllerFactory.php @@ -58,19 +58,27 @@ * @return PanaceaPageController */ public function getController(array $uriFragments) { - if (count($uriFragments) < 2) { - throw new InvalidTypeException(1, 'array with at least two elements', $uriFragments); + if (empty($uriFragments)) { + throw new InvalidTypeException(1, 'non-empty array', $uriFragments); } $section = ''; $page = $uriFragments[0]; if (isset($uriFragments[1])) { - $section = $uriFragments[0]; + $section = ucfirst($uriFragments[0]); $page = $uriFragments[1]; } + if (empty($section)) { + $section = 'Default'; + } + if (empty($page)) { + $page = 'home'; + } - return new PanaceaPageController($uriFragments[0]); + $controllerName = 'Panacea' . $section . 'Controller'; + + return new $controllerName($page); } } diff --git a/src/lib/PanaceaPageController.php b/src/lib/PanaceaPageController.php index b3309bc..a730002 100644 --- a/src/lib/PanaceaPageController.php +++ b/src/lib/PanaceaPageController.php @@ -1,7 +1,7 @@