/** * @Route("/new") */ public function newAction(Request $request) { $task = new Task(); $estimation = new Estimation(); $estimation->setTime(7); $task->addEstimation($estimation); $form = $this->createForm(new TaskType(), $task); $form->add('save', 'submit'); return $this->render('EstAppBundle:Default:new.html.twig', array('form' => $form->createView())); }
public function load(ObjectManager $manager) { $estimations = array(array('task 1 sub 1 sub 1', 'tech 1', 2), array('task 1 sub 1 sub 2', 'tech 1', 3), array('task 1 sub 2', 'tech 1', 4)); foreach ($estimations as $e) { $estimation = new Estimation(); $estimation->setTask($this->getReference($e[0])); $estimation->setTechnology($this->getReference($e[1])); $estimation->setTime($e[2]); $manager->persist($estimation); } $manager->flush(); }
/** * Add estimation * * @param \Est\AppBundle\Entity\Estimation $estimation * * @return Task */ public function addEstimation(\Est\AppBundle\Entity\Estimation $estimation) { $this->estimations[] = $estimation; $estimation->setTask($this); return $this; }