/**
  * {@inheritDoc}
  */
 public function getVehicle()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getVehicle', array());
     return parent::getVehicle();
 }
Esempio n. 2
0
 public function processAction()
 {
     $sefssion = $this->getEntityManager()->getRepository('Admin\\Entity\\Session')->findOneBy(array(), array('id' => 'DESC'));
     $session = $sefssion->getId();
     $post = $this->getRequest()->getPost()->toArray();
     $vehicle = $_POST['vehicle'];
     $route = $_POST['route'];
     $driver = $_POST['driver'];
     $fare = $_POST['fare'];
     //var_dump($post);die;
     foreach ($route as $key => $n) {
         $routeid = $this->getEntityManager()->getRepository('Transport\\Entity\\Route')->findOneBy(array('id' => $n));
         $vehicleid = $this->getEntityManager()->getRepository('Transport\\Entity\\Vehicle')->findOneBy(array('id' => $vehicle[$key]));
         $driverid = $this->getEntityManager()->getRepository('Admin\\Entity\\Staff')->findOneBy(array('id' => $driver[$key]));
         $settings = $this->getEntityManager()->getRepository('Transport\\Entity\\SessionRoute')->findOneBy(array('route' => $n, 'session' => $session, 'vehicle' => $vehicle[$key], 'driver' => $driver[$key]));
         if (isset($settings)) {
             $settings->setRoute($routeid);
             $settings->setVehicle($vehicleid);
             $settings->setDriver($driverid);
             $settings->setFare($fare[$key]);
             $this->getEntityManager()->persist($settings);
         } else {
             $settings = new SessionRoute();
             $settings->setRoute($routeid);
             $settings->setVehicle($vehicleid);
             $settings->setDriver($driverid);
             $settings->setFare($fare[$key]);
             $settings->setSession($sefssion);
             $this->getEntityManager()->persist($settings);
         }
     }
     $this->getEntityManager()->flush();
     return $this->redirect()->toRoute('transport', array('controller' => 'transport', 'action' => 'settings'));
     return new ViewModel();
 }