changed directory structure to match namespace
This commit is contained in:
29
src/Webservice/Renderer.php
Normal file
29
src/Webservice/Renderer.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace BSR\Webservice;
|
||||
|
||||
use BSR\Webservice\Formatter\Formatter;
|
||||
|
||||
class Renderer {
|
||||
private static $statusMessages = array(
|
||||
200 => 'Ok',
|
||||
400 => 'Bad request',
|
||||
404 => 'Not Found',
|
||||
403 => 'Not Authorized',
|
||||
500 => 'Server Error',
|
||||
);
|
||||
|
||||
public function __construct() {
|
||||
ob_start();
|
||||
}
|
||||
|
||||
public function render($status, $data) {
|
||||
header(sprintf('HTTP/1.0 %s %s', $status, self::$statusMessages[$status]));
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
ob_clean();
|
||||
flush();
|
||||
|
||||
$formatter = Formatter::getFormatter();
|
||||
$formatter->render($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user