Example #1
0
 /**
  * Import a new Sensor after checking that this is a new one (sensor list page).
  *
  * @param string     $rom        the ROM address of the sensor
  * @param SensorType $sensorType the type of sensor (i.e : thermometer, humidity sensory, light sensor)
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function importSensorAction($rom, SensorType $sensorType)
 {
     $sensor = new Sensor();
     $sensor->setName("Sensor " . time());
     $sensor->setType($sensorType);
     $sensor->setRom($rom);
     $sensor->setLastSeen(new \DateTime());
     $entityManager = $this->getDoctrine()->getManager();
     $entityManager->persist($sensor);
     $entityManager->flush($sensor);
     return $this->redirect($this->generateUrl('weather_sensors_edit', ['id' => $sensor->getId()]));
 }