public function saveRouteAction()
 {
     $message = ErMessenger::getInstance();
     $request = new Request();
     $request->initRequest();
     $post = $request->getPost();
     $userEmail = ErSession::getFromSession('user');
     $roadMapper = new RoadMapper();
     $road = new Roadrout();
     $road->id = (string) time();
     $road->driverid = $userEmail;
     $road->start = $post['id_citystart'];
     $road->start_adress = $post['id_streetstart'];
     $road->finish = $post['id_cityfinish'];
     $road->finish_adress = $post['id_streetfinish'];
     $road->terms = $post['dopinfo'];
     $road->autoid = $post['regnumber'];
     $road->freeseats = $post['seats'];
     $road->price = $post['price'];
     $road->startdate = $post['dateDep'];
     $road->timetrip = $post['dateArrival'];
     $road->status = 'opened';
     if ($roadMapper->insertNewRoad($road)) {
         $message->setSucceedMessage('202', 'index/index');
         ErApplication::redirect('/');
     } else {
         $message->setErrMessage('100', 'road/addRoute');
         ErApplication::redirect('road/addRoute');
     }
 }
 protected function fetchUserData($userEmail)
 {
     $result = array();
     $userMapper = new UserMapper();
     $carMapper = new CarMapper();
     $routeMapper = new RoadMapper();
     $currentUser = $userMapper->getUserByEmail($userEmail);
     $userCars = $carMapper->getByUser($userEmail);
     $userRoutes = $routeMapper->getByUser($userEmail);
     $routes = array();
     $carMapper->clear();
     $i = 0;
     foreach ($userRoutes as $route) {
         $routes[$i] = get_object_vars($route);
         $_car = $carMapper->getByAutoId($route->autoid);
         $routes[$i]['car'] = get_object_vars($_car);
         $carMapper->clear();
         ++$i;
     }
     $cars = array();
     foreach ($userCars as $car) {
         $cars[] = get_object_vars($car);
     }
     $result['user'] = get_object_vars($currentUser);
     $result['user']['age'] = $currentUser->getAge();
     $result['cars'] = $cars;
     $result['routes'] = $routes;
     return $result;
 }