Content-Negotiation with the help of Renderer and Formatters

This commit is contained in:
Gilles Crettenand
2015-06-02 02:02:40 +02:00
parent c0159f4b79
commit 7e0a38e989
7 changed files with 241 additions and 23 deletions

17
Lib/Formatter/Json.php Normal file
View File

@@ -0,0 +1,17 @@
<?php
namespace BSR\Lib\Formatter;
class Json extends Formatter {
protected static function init() {
self::registerFormats(array(
'application/json',
'application/x-json',
));
}
public function render($data) {
echo json_encode($data);
}
}