1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 9/30/16
- * Time: 8:57 PM
- */
-
- namespace App\DataAccess;
-
-
- use App\Business\MiscBusiness;
- use App\Dbo\StopsDbo;
- use GuzzleHttp\Client;
- use Luticate\Utils\Controller\LuticateApplication;
- use Luticate\Utils\Dbo\LuPaginatedDbo;
-
- class StopsDataAccess
- {
- public static function getAll(string $resourceId, string $type)
- {
- $client = new Client();
- $entrypoint = LuticateApplication::getInstance()->getSetting("API_ENTRYPOINT");
- $response = $client->request("GET", $entrypoint . "transit/${resourceId}/${type}/stops.json");
- $data = json_decode($response->getBody(), true);
- /**
- * @var $dbos StopsDbo[]
- */
- $dbos = [];
- foreach ($data["features"] as $stop) {
- $dbo = new StopsDbo();
- $dbo->setId($stop["id"]);
- $dbo->setName($stop["properties"]["name"]);
- $dbo->setPosX($stop["geometry"]["coordinates"][0]);
- $dbo->setPosY($stop["geometry"]["coordinates"][1]);
- $dbo->setRoutes($stop["properties"]["route_ids"]);
- $dbos[] = $dbo;
- }
- return $dbos;
- }
- }
|