BUGFIX: Added better handling of rendering SiteTree objects, to prevent test errors. (from r89963) (from r96729)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102351 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 01:53:16 +00:00
parent 093da7592a
commit d56bc3e4dc
3 changed files with 25 additions and 2 deletions

View File

@ -280,7 +280,12 @@ class Director {
$controllerObj = new $controller();
$controllerObj->setSession($session);
return $controllerObj->handleRequest($request);
$result = $controllerObj->handleRequest($request);
if(!is_object($result) || $result instanceof HTTPResponse) return $result;
user_error("Bad result from url " . $request->getURL() . " handled by " .
get_class($controllerObj)." controller: ".get_class($result), E_USER_WARNING);
}
}
}

View File

@ -17,7 +17,8 @@ class ModelAsController extends Controller implements NestedController {
* @return ContentController
*/
public static function controller_for(SiteTree $sitetree, $action = null) {
$controller = "{$sitetree->class}_Controller";
if($sitetree->class == 'SiteTree') $controller = "ContentController";
else $controller = "{$sitetree->class}_Controller";
if($action && class_exists($controller . '_' . ucfirst($action))) {
$controller = $controller . '_' . ucfirst($action);
@ -54,6 +55,9 @@ class ModelAsController extends Controller implements NestedController {
if($result instanceof RequestHandler) {
$result = $result->handleRequest($this->request);
} else if(!($result instanceof HTTPResponse)) {
user_error("ModelAsController::getNestedController() returned bad object type '" .
get_class($result)."'", E_USER_WARNING);
}
} catch(SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();

View File

@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<!-- very simple template that exists mainly so that edge cases like test execution don't fail -->
<head>
<% base_tag %>
$MetaTags
</head>
<body>
<h1>$Title</h1>
$Content
<p><i>Generated with the default ContentController.ss template</i></p>
</body>
</html>