12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 9/30/16
- * Time: 8:57 PM
- */
-
- namespace App\DataAccess;
-
- use App\Dbo\RoutesDbo;
- use GuzzleHttp\Client;
- use Luticate\Utils\Controller\LuticateApplication;
-
- class RoutesDataAccess
- {
- 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}/routes.json");
- $data = json_decode($response->getBody(), true);
- /**
- * @var $dbos RoutesDbo[]
- */
- $dbos = [];
- foreach ($data["data"] as $route) {
- $dbo = new RoutesDbo();
- $dbo->setId($route["id"]);
- $dbo->setName($route["name"]);
- $dbo->setBgColor($route["color"] == null ? "#ffffff" : $route["color"]);
- $dbo->setFgColor($route["text_color"] == null ? "#aa0000" : $route["text_color"]);
- $dbos[] = $dbo;
- }
- return $dbos;
- }
- }
|