/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Generating people...'); /** @var \Doctrine\ORM\EntityManager $entityManager */ $entityManager = $this->getContainer()->get('doctrine')->getManager(); $faker = Factory::create(); $people = array(); for ($i = 0; $i < self::$NUMBER_Of_PERSONS; $i++) { $person = new Person(); $gender = rand(0, 1) == 0 ? Gender::MALE() : Gender::FEMALE(); $person->setFirstName($faker->format("firstName", array($gender->getName()))); $person->setLastName($faker->lastName); $person->setGender($gender); $person->setBirthday($faker->dateTimeBetween('-60 years', '-18 years')); $entityManager->persist($person); $people[] = $person; $output->write('.'); } $output->writeln(''); $output->writeln('Generating calendars with appointments...'); for ($i = 0; $i < self::$NUMBER_Of_CALENDARS; $i++) { $calendar = new Calendar(); $calendar->setPerson($faker->randomElement($people)); $entityManager->persist($calendar); for ($j = 0; $j < $faker->randomDigit; $j++) { $appointment = new Appointment(); $appointment->setWhen($faker->dateTimeThisYear); $appointment->setWhat($faker->text); $appointment->setCalendar($calendar); $entityManager->persist($appointment); } $output->write('.'); } $entityManager->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { $customer = $manager->getRepository("AppBundle:Customer")->findOneBy(array('firstname' => 'Bampis')); $appointment = new Appointment(); $appointment->setComments("Appointment Test Fixture"); $appointment->setDate(new \DateTime()); $appointment->setIsCompleted(false); $appointment->setTitle("Test Appointment"); $appointment->setCustomer($customer); $manager->persist($appointment); $manager->flush(); }
/** * Creates a form to delete a Appointment entity by id. * * @param Appointment $appointment * * @return \Symfony\Component\Form\Form */ private function createDeleteForm(Appointment $appointment) { return $this->createFormBuilder()->setAction($this->generateUrl('appointment_delete', array('id' => $appointment->getId())))->setMethod('DELETE')->getForm(); }