updated controller/view factories; renamed PanaceaPageController to PanaceaDefaultController

This commit is contained in:
tmont 2008-10-18 19:55:18 +00:00
parent 14cfcb9610
commit 1e413db8c9
4 changed files with 17 additions and 13 deletions

View File

@ -24,7 +24,7 @@
$file = ''; $file = '';
switch ($className) { switch ($className) {
case 'PanaceaControllerFactory': case 'PanaceaControllerFactory':
case 'PanaceaPageController': case 'PanaceaDefaultController':
case 'PanaceaViewFactory': case 'PanaceaViewFactory':
$file = "$path/lib/$className.php"; $file = "$path/lib/$className.php";
break; break;

View File

@ -58,19 +58,27 @@
* @return PanaceaPageController * @return PanaceaPageController
*/ */
public function getController(array $uriFragments) { public function getController(array $uriFragments) {
if (count($uriFragments) < 2) { if (empty($uriFragments)) {
throw new InvalidTypeException(1, 'array with at least two elements', $uriFragments); throw new InvalidTypeException(1, 'non-empty array', $uriFragments);
} }
$section = ''; $section = '';
$page = $uriFragments[0]; $page = $uriFragments[0];
if (isset($uriFragments[1])) { if (isset($uriFragments[1])) {
$section = $uriFragments[0]; $section = ucfirst($uriFragments[0]);
$page = $uriFragments[1]; $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);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PanaceaPageController * PanaceaDefaultController
* *
* @package Panacea * @package Panacea
* @author Tommy Montgomery * @author Tommy Montgomery
@ -12,16 +12,16 @@
require_once 'NowhereConcave/bootstrap.php'; require_once 'NowhereConcave/bootstrap.php';
/** /**
* Panacea page controller * Panacea controller
* *
* @package Panacea * @package Panacea
* @author Tommy Montgomery * @author Tommy Montgomery
* @since 2008-10-05 * @since 2008-10-05
*/ */
class PanaceaPageController extends Controller { class PanaceaDefaultController extends Controller {
/** /**
* Creates a new {@link Controller} * Creates a new {@link PanaceaDefaultController}
* *
* @author Tommy Montgomery * @author Tommy Montgomery
* @since 2008-10-05 * @since 2008-10-05

View File

@ -61,10 +61,6 @@
throw new InvalidTypeException(1, 'string', $page); throw new InvalidTypeException(1, 'string', $page);
} }
if (empty($page)) {
$page = 'home';
}
$viewName = 'Panacea' . ucfirst($page) . 'View'; $viewName = 'Panacea' . ucfirst($page) . 'View';
try { try {