26 public function get($objects, $pages =
null) {
27 $objects = $this->
getDatas($objects);
28 return $this->
format($objects);
38 public function getDatas($objects, &$classname =
null) {
39 $objects = \array_map(
function ($o) use (&$classname) {
42 return \array_values($objects);
58 foreach ($o as $k => $v) {
59 if (isset ($v->_rest)) {
63 foreach ($v as $index => $values) {
64 if (isset ($values->_rest))
89 public function format($arrayResponse) {
93 return \json_encode($arrayResponse);
103 $array = \explode(
"\\", $controllerName);
104 $result = \ucfirst(end($array));
105 if (UString::endswith($result,
"s")) {
106 $result = \substr($result, 0, -1);
118 return \json_encode($data);
128 $error =
new RestError (@$e->getCode(), @$e->getMessage(), @$e->getTraceAsString(), @$e->getFile(), 500);
129 return $this->
format($error->asArray());
132 public static function toXML($data, &$xml_data) {
133 foreach ($data as $key => $value) {
134 if (is_numeric($key)) {
135 $key =
'item' . $key;
137 if (is_array($value)) {
138 $subnode = $xml_data->addChild($key);
141 $xml_data->addChild(
"$key", htmlspecialchars(
"$value"));