public function updateDirections() { //Fetch all the routes that are already in the database try { $routeArray = Route::getRoutes($this->agency); } catch (Exception $ex) { throw new Exception("BART directions could not be updated"); } foreach ($routeArray as $routeTag => $routeObj) { //Build an array of direction objects $directionInfo = array(); //Add the directions for every route foreach ($this->xml->routes->route as $d) { $tempRouteTag = BartColorCodes::getBartColor(substr((string) $d->color, 1)); if ($tempRouteTag == $routeTag) { $dirObj = new Direction(); $dirTag = (string) $d->number; $useForUiValue = true; //Always true for BART $dirObj->setRoute($routeObj); $dirObj->setTag($dirTag); $dirObj->setTitle($this->formatTitle((string) $d->name)); $dirObj->setName((string) $d->abbr); $dirObj->setUseForUi($useForUiValue); $dirObj->setShow($useForUiValue); $directionInfo[$dirTag] = $dirObj; } } //var_dump($directionInfo);exit; //Update the database try { //Pass it to the base DirectionUpdate class $dirUpdate = new DirectionUpdate($routeObj, $directionInfo); $dirUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } } }
public function updateDirections() { //Fetch all the routes that are already in the database try { $routeArray = Route::getRoutes($this->agency); } catch (Exception $ex) { throw new Exception("Nextbus directions could not be updated. Error building route array."); } //Add the directions for every route foreach ($this->xml->route as $r) { $routeTag = (string) $r['tag']; $routeObj = $routeArray[$routeTag]; //Build an array of direction objects $directionInfo = array(); foreach ($r->direction as $d) { $dirObj = new Direction(); $dirTag = (string) $d['tag']; $useForUiValue = (string) $d['useForUI'] == "false" ? false : true; $dirObj->setRoute($routeObj); $dirObj->setTag($dirTag); $dirObj->setTitle((string) $d['title']); $dirObj->setName((string) $d['name']); $dirObj->setUseForUi($useForUiValue); $dirObj->setShow($this->getShowValue($routeTag, $dirTag, $useForUiValue)); $directionInfo[$dirTag] = $dirObj; } //Update the database try { //Pass it to the base DirectionUpdate class $dirUpdate = new DirectionUpdate($routeObj, $directionInfo); $dirUpdate->updateDB(); } catch (Exception $ex) { throw new Exception($ex->getMessage()); } } }