Exemplo n.º 1
0
 public function renderShow($id)
 {
     $service = new TripService($this->entityManager);
     $trip = $service->find($id);
     $this->template->trip = $trip;
     try {
         $eventService = new EventService();
         $config = Environment::getConfig('api');
         $events = $eventService->getEvents($trip->arrival, new DateTime(), new EventfulMapper($config->eventfulUser, $config->eventfulPassword, $config->eventfulKey));
         $this->template->events = $events;
     } catch (InvalidStateException $e) {
         $this->template->events = array();
     }
     $articleService = new ArticleService($this->entityManager);
     $this->template->article = $articleService->buildArticle($trip->arrival, new ArticleWikipediaMapper());
     try {
         $airportMapper = new AirportTravelMathMapper();
         $airportService = new AirportService();
         $locationService = new LocationService();
         $coordinates = $locationService->getCoordinates($trip->getDeparture());
         $from = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $coordinates = $locationService->getCoordinates($trip->getArrival());
         $to = $airportService->searchNearestAirport($airportMapper, $coordinates['latitude'], $coordinates['longitude']);
         $flightMapper = new FlightKayakMapper();
         $flightService = new FlightService($this->entityManager);
         $depart_date = new DateTime('now');
         $return_date = new DateTime('+1 week');
         $this->template->flights = $flightService->buildFlights($flightMapper, $from, $to, $depart_date, $return_date, '1', 'e', 'n');
     } catch (FlightException $e) {
         $this->template->flightsError = "Connection with search system <a href='http://kayak.com'>Kayak</a> failed.";
     } catch (AirportException $e) {
         $this->template->flightsError = $e->getMessage();
     }
 }
Exemplo n.º 2
0
<?php

require_once "airportservice.php";
$country_code = isset($_GET['country_code']) ? $_GET['country_code'] : '';
/*
een assoc array wordt door json_encode in een JS object omgezet { }, een geindexeerd array in een gewoon array [ ]
de extra param 'options' werkt pas vanaf PHP 5.3
$output = json_encode($team,JSON_FORCE_OBJECT);
*/
$apService = new AirportService();
if (!isset($_GET['country_code'])) {
    //$output = "{}";
    $output = $apService->geefJSONAlleAirports();
} else {
    $output = $apService->geefJSONAirportsByCountryCode($country_code);
}
//header('Content-type: application/json');
echo $output;
Exemplo n.º 3
0
<?php

require_once "airportservice.php";
$country_code = isset($_GET['country_code']) ? $_GET['country_code'] : '';
/*
een assoc array wordt door json_encode in een JS object omgezet { }, een geindexeerd array in een gewoon array [ ]
de extra param 'options' werkt pas vanaf PHP 5.3
$output = json_encode($team,JSON_FORCE_OBJECT);
*/
$apService = new AirportService();
if (!isset($_GET['country_code'])) {
    //$output = "{}";
    $output = $apService->geefJSONAlleCountries();
} else {
    $output = $apService->geefJSONCountryByCountryCode($country_code);
}
//header('Content-type: application/json');
echo $output;