Exemplo n.º 1
0
 /**
  * Execute a search call to the service.
  * @param array $parameters
  *   Parameters to be used in the request.
  * @return SearchResult
  */
 public function search($parameters = array())
 {
     $response = $this->executeSearch('search', $parameters);
     return SearchResult::fromXml(new SimpleXMLElement($response->getBody(true), 0, false, $this->cdbXmlNamespaceUri), $this->cdbXmlNamespaceUri);
 }
Exemplo n.º 2
0
    /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
    $session = $app['session'];
    $session->invalidate();
    return new Response('Logged out');
});
$app->get('search', function (Request $request, Application $app) {
    $q = $request->query->get('q');
    $limit = new \CultuurNet\Search\Parameter\Rows($request->query->get('limit', 30));
    $start = new \CultuurNet\Search\Parameter\Start($request->query->get('start', 0));
    $group = new \CultuurNet\Search\Parameter\Group();
    $typeFilter = new \CultuurNet\Search\Parameter\FilterQuery('type:event');
    /** @var SearchAPI2 $service */
    $service = $app['search_api_2'];
    $q = new \CultuurNet\Search\Parameter\Query($q);
    $response = $service->search(array($q, $limit, $start, $group, $typeFilter));
    $results = \CultuurNet\Search\SearchResult::fromXml(new SimpleXMLElement($response->getBody(true), 0, false, \CultureFeed_Cdb_Default::CDB_SCHEME_URL));
    $response = Response::create()->setContent($results->getXml())->setPublic()->setClientTtl(60 * 1)->setTtl(60 * 5);
    $response->headers->set('Content-Type', 'text/xml');
    return $response;
})->before($checkAuthenticated);
$app->get('api/1.0/event.jsonld', function (Request $request, Application $app) {
    $response = new \Symfony\Component\HttpFoundation\BinaryFileResponse('api/1.0/event.jsonld');
    $response->headers->set('Content-Type', 'application/ld+json');
    return $response;
});
$app->get('api/1.0/search', function (Request $request, Application $app) {
    $query = $request->query->get('query', '*.*');
    $limit = $request->query->get('limit', 30);
    $start = $request->query->get('start', 0);
    $sort = $request->query->get('sort', 'lastupdated desc');
    /** @var Psr\Log\LoggerInterface $logger */