Files
DomFramework/src/Outputrest.php

42 lines
1.5 KiB
PHP

<?php
/** DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework;
/** 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...)
* @param string|null $module The module name to use if needed
* @return mixed 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 = "")
{
$code = http_response_code();
if (isset ($variable["exceptionCode"]))
$code = $variable["exceptionCode"];
$rest = new Rest ();
$rest->display ($data, $code);
}
}