add Kernel option to return raw content
This commit is contained in:
parent
a4fcfb08e3
commit
0446757cbb
@ -64,15 +64,21 @@ final class controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$B_called = call_user_func_array(array(
|
$called = call_user_func_array(array(
|
||||||
new $this->_A_urlParts['controller'],
|
new $this->_A_urlParts['controller'],
|
||||||
$this->_A_urlParts['action']),
|
$this->_A_urlParts['action']),
|
||||||
array($this->_A_urlParams, $this->_A_postParams, $this->_A_getParams)
|
array($this->_A_urlParams, $this->_A_postParams, $this->_A_getParams)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (false === $B_called) {
|
if (false === $called) {
|
||||||
throw new ControllerException("Action " . $this->_A_urlParts['action'] .
|
throw new ControllerException("Action " . $this->_A_urlParts['action'] .
|
||||||
" of controller " . $this->_A_urlParts['controller'] . " failed.");
|
" of controller " . $this->_A_urlParts['controller'] . " failed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Utils::RETURN_RAW === $called){
|
||||||
|
return Utils::RETURN_RAW;
|
||||||
|
}else{
|
||||||
|
return Utils::RETURN_HTML;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,9 @@
|
|||||||
final class Utils
|
final class Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public const RETURN_HTML = 2;
|
||||||
|
public const RETURN_RAW = 3;
|
||||||
|
|
||||||
public static function getOrDie($DICT, $key)
|
public static function getOrDie($DICT, $key)
|
||||||
{
|
{
|
||||||
if (isset($DICT[$key])) return $DICT[$key];
|
if (isset($DICT[$key])) return $DICT[$key];
|
||||||
|
|||||||
10
index.php
10
index.php
@ -19,7 +19,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$O_controller = new Controller($S_url, $A_postParams, $A_getParams);
|
$O_controller = new Controller($S_url, $A_postParams, $A_getParams);
|
||||||
$O_controller->execute();
|
$ret = $O_controller->execute();
|
||||||
}
|
}
|
||||||
catch (ControleurException $O_exception)
|
catch (ControleurException $O_exception)
|
||||||
{
|
{
|
||||||
@ -29,4 +29,10 @@
|
|||||||
|
|
||||||
$content = View::closeBuffer();
|
$content = View::closeBuffer();
|
||||||
|
|
||||||
View::show('html', array('body' => $content));
|
if($ret === Utils::RETURN_HTML){
|
||||||
|
View::show('html', array('body' => $content));
|
||||||
|
}else if($ret === Utils::RETURN_RAW){
|
||||||
|
echo $content;
|
||||||
|
}else{
|
||||||
|
throw new Exception("Invalid return value: $ret");
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user