public function doItWith($lat, $lng, $name)
 {
     $repo = $this->getDoctrine()->getManager()->getRepository('AppBundle:User');
     $allUsers = $repo->findAll();
     $notes = array("I arrived safely! The people here are very nice, but it is a bit cold.", "The weather is still warm and sunny, and we have enough food. We will continue the trip on the 18th of November.", "Mom, I will be here for 5 days. I'll be on Skype every day from 4 to 6pm if you can come and talk to me", "Alli, don't go through Hungary, the roads are too dangerous right now. I would advise you to stay in Serbia. Stay safe.", "I reach the camp safely today. There is not much food, but we have shelter and water. Please let me know you are okay!", "The bus was late 2h but we reached Frankfurt finally! I will get a job soon and send for you guys. Stay safe.", "Me and Edin reached Serbia today via train. The people are nice and the conditions are okay.", "Aadil and Amir are with me, we were able to meetup in Zagreb like we planned. The border is not safe, but we have shelter and supplies. Stay safe dad!", "Aasif, do not go over the border yet. Keep Abdul and you sister safe. We will meet in Nish.");
     foreach ($allUsers as $user) {
         $max = 0;
         $finish = rand(count($lat) - 3, count($lat));
         $days = 0;
         while ($max < $finish) {
             $status = new Status();
             $status->setLtd($lat[$max] + rand(0.01, 0.001));
             $status->setLng($lng[$max] + rand(0.01, 0.001));
             $status->setLocation($name[$max]);
             $status->setNote($notes[rand(0, count($notes) - 1)]);
             $status->setUser($user);
             $days = $days + rand(1, 5);
             $str = $days . " days ago";
             $status->setDate(new \DateTime($str));
             $max = rand($max + 1, min($finish - 1, $max + rand(1, 3)));
             $em = $this->getDoctrine()->getManager();
             $em->persist($status);
             $em->flush();
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Creates a form to delete a Status entity.
  *
  * @param Status $status The Status entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Status $status)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('status_delete', array('id' => $status->getId())))->setMethod('DELETE')->getForm();
 }