Add : outputrest to support the routing to REST
$route->output = "rest"; git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2943 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
37
outputrest.php
Normal file
37
outputrest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/** DomFramework
|
||||||
|
@package domframework
|
||||||
|
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||||
|
|
||||||
|
require_once ("output.php");
|
||||||
|
require_once ("rest.php");
|
||||||
|
/** Display in REST the data provided.
|
||||||
|
* Allow all the output types : JSON, XML, TXT...
|
||||||
|
*/
|
||||||
|
class outputrest extends output
|
||||||
|
{
|
||||||
|
/** Data is printed by viewClass->viewmethod, in the middle of $layout
|
||||||
|
* title is put in the title of the HTML page
|
||||||
|
* $replacement modify the result (it can do title too :
|
||||||
|
* array ("{title}"=>"title to display")
|
||||||
|
* @param mixed $data Data to display on the page
|
||||||
|
* @param string|null $title Title to put on head of page
|
||||||
|
* @param string|null $viewClass Class in views to use to display
|
||||||
|
* @param string|null $viewMethod Method in the class in views
|
||||||
|
* @param string|null $layout Layout file in views
|
||||||
|
* @param array|null $replacement Replace the {key}=>value
|
||||||
|
* @param array|null $variable PHP variables send to the view and to layout
|
||||||
|
* (can be processed by foreach, if...)
|
||||||
|
* @return Exit from PHP at the end of HTML display
|
||||||
|
*/
|
||||||
|
public function out ($data, $title = FALSE,
|
||||||
|
$viewClass = FALSE, $viewMethod = FALSE,
|
||||||
|
$layout = FALSE, $replacement = array(),
|
||||||
|
$variable = array (), $module = "")
|
||||||
|
{
|
||||||
|
if (! isset ($variable["exceptionCode"]))
|
||||||
|
$variable["exceptionCode"] = 200;
|
||||||
|
$rest = new \rest ();
|
||||||
|
$rest->display ($data, $variable["exceptionCode"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -614,7 +614,11 @@ class route
|
|||||||
"{exceptionText}"=>$http->codetext($getCode),
|
"{exceptionText}"=>$http->codetext($getCode),
|
||||||
"{baseurl}"=>$this->baseURL(),
|
"{baseurl}"=>$this->baseURL(),
|
||||||
"{baseurlmodule}"=>$this->baseURLmodule()));
|
"{baseurlmodule}"=>$this->baseURLmodule()));
|
||||||
$renderer->variable = $this->variable;
|
$renderer->variable = array_merge ($this->variable,
|
||||||
|
array ("exceptionCode"=>$getCode,
|
||||||
|
"exceptionText"=>$http->codetext($getCode),
|
||||||
|
"baseurl"=>$this->baseURL(),
|
||||||
|
"baseurlmodule"=>$this->baseURLmodule()));
|
||||||
$renderer->run ();
|
$renderer->run ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user