Example #1
0
<?php

$serializer = SerializerFactory::getSerializer('contacts');
// $user_id = isset($_GET['uid']) ? $_GET['uid'] : null;
$data = $serializer->getData($_GET);
//get is actually supoer global, but nvm that, it is probper to pass the request as parameter to the serializer
if ($data && $data['list'] && sizeof($data['list']) > 0) {
    Router::Render('contacts', $data);
} else {
    Router::RenderEmptyResultSet('contacts');
}
Example #2
0
<?php

$serializer = SerializerFactory::getSerializer('users');
$data = $serializer->getData();
//get is actually supoer global, but nvm that, it is probper to pass the request as parameter to the serializer
Router::Render('users', $data);
Example #3
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/src/includes.php';
if (!isset($_GET['endpoint']) || !$_GET['endpoint']) {
    http_response_code(400);
    exit(1);
    // throw new exception('Status code: 400');//Raise 400 error, bad request
}
$serializer = SerializerFactory::getSerializer($_GET['endpoint']);
if ($serializer && is_callable(array($serializer, 'getData'))) {
    //TODO: create abstract serializer class and to check that $serializer is instanceOf it
    $data = $serializer->getData($_GET);
    //get is actually supoer global, but nvm that, it is probper to pass the request as parameter to the serializer
} else {
    http_response_code(400);
    exit(1);
    // throw new exception('Status code:  400');//raid 400, bad request, TODO: catch this exception and uncomment
}
if (isset($data) && isset($data['list']) && sizeof($data['list']) > 0) {
    Router::Render($_GET['endpoint'], $data);
} else {
    $fullName = isset($data, $data['__fullName']) ? $data['__fullName'] : null;
    Router::RenderEmptyResultSet($_GET['endpoint'], $fullName);
}
?>
 
Example #4
0
<?php

$serializer = SerializerFactory::getSerializer('bdays');
// $user_id = isset($_GET['uid']) ? $_GET['uid'] : null;
$data = $serializer->getData($_GET);
//get is actually supoer global, but nvm that, it is probper to pass the request as parameter to the serializer
if ($data && $data['list'] && sizeof($data['list']) > 0) {
    Router::Render('bdays', $data);
} else {
    Router::RenderEmptyResultSet('bdays');
}