Skip to content
Snippets Groups Projects

Added /v1

Merged Ernst, Marcus requested to merge dev into master
1 file
+ 62
100
Compare changes
  • Side-by-side
  • Inline
+ 62
100
@@ -16,106 +16,68 @@ $queryManager = function ($request, $response, $next) {
return $response;
};
$app->group('/bpapi', function(){
$this->get('/all/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->all($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/collection/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->collection($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/biography/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->biography($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/bibliography/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->bibliography($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/collector/{id}', function($request, $response, $args){
#$response->getBody()->write('Test started<br>');
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$result = $qmo->collector($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
#### RDF to JSON-LD ####
#$new = new \ML\JsonLD\JsonLD();
#$result = $new->fromRdf($result);
/*
$context = json_encode(array('@context' => array('@vocab' => 'http://schema.org/')));
$new = new \ML\JsonLD\JsonLD();
$expanded = $new->compact($result, $context);
$result = $expanded;
$result = $new->toString($expanded, true);
header('Content-Type: application/json');
echo $result;
#$result = json_decode($result);
*/
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
#var_dump($testResult);
#$route = $request->getAttribute('route');
#var_dump($route->getArguments()); # get collector id
#$response->getBody()->write('FIRST ');
#return $request;
$app->group('/api', function(){
$this->group('/v1', function(){
$this->get('/all/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->all($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/collection/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->collection($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/biography/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->biography($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
$this->get('/bibliography/{id}', function($request, $response, $args){
$qmo = $request->getAttribute('queryManagerObject');
$collector = $request->getAttribute('id');
$qmo->setId($collector);
$result = $qmo->bibliography($collector);
$result = json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
if (!isset($result)) {
return $response->withJSON(["status"=>"404 - Not found"], 404);
}
return $response->withJSON(["status"=>"200 - Ok", "result"=>json_decode($result)])->withHeader('Content-Type', 'application/ld+json');
return $request;
});
});
})->add($queryManager);
Loading