Ejemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $faker = $this->getFaker();
     $fly1 = new Fly();
     $fly1->setName('chateau des vaux');
     $fly1->setLatitude('48');
     $fly1->setLongitude('1.0');
     $fly1->setDescription('magnifique chateau de la region ');
     $fly1->setCategory($faker->randomElement($fly1->getCategoryValues()));
     $manager->persist($fly1);
     $manager->flush();
     $lon_min = -1.0522795;
     $lon_max = 6.7260408;
     $lat_min = 42.4838724;
     $lat_max = 49.66374;
     foreach (range(1, 20) as $id) {
         $fly = new Fly();
         $fly->setName($faker->userName);
         $fly->setDescription($faker->realText(250));
         $fly->setLatitude(mt_rand() / mt_getrandmax() * ($lat_max - $lat_min) + $lat_min);
         $fly->setLongitude(mt_rand() / mt_getrandmax() * ($lon_max - $lon_min) + $lon_min);
         $fly->setCategory($faker->randomElement($fly1->getCategoryValues()));
         $manager->persist($fly);
     }
     $manager->flush();
 }
Ejemplo n.º 2
0
 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('name')->add('latitude')->add('longitude')->add('description')->add('category', 'choice', array('choices' => Fly::getCategories(), 'expanded' => false, 'multiple' => false, 'required' => true))->add('file', 'file', array('label' => 'Fly logo', 'required' => false));
 }