Example #1
0
 public function newAction(Request $request)
 {
     $task = new Task();
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $tag1->addTask($task);
     $task->getTags()->add($tag1);
     $form = $this->createForm(TaskType::class, $task, array('roles' => 1));
     $form->handleRequest($request);
     //        $tags = $description->getTa
     if ($form->isValid()) {
         $data = $form->getData();
         $description = $data->getDescription();
         $tags = new ArrayCollection();
         $tags = $data->getTags();
         foreach ($tags as $tag) {
             $tag->addTask($description);
         }
         $em = $this->getDoctrine()->getManager();
         $em->persist($tag);
         $em->flush();
     }
     return $this->render('AppBundle:Task:new.html.twig', array('form' => $form->createView()));
 }
Example #2
0
 public function load(ObjectManager $manager)
 {
     $task = new Task();
     $task->setDescription('task one');
     // dummy code - this is here just so that the Task has some tags
     // otherwise, this isn't an interesting example
     $tag1 = new Tag();
     $tag1->setName('tag1');
     $tag1->addTask($task);
     $task->getTags()->add($tag1);
     $manager->persist($task);
     $manager->flush();
 }
Example #3
0
 public function addTag(Tag $tag)
 {
     $tag->addTask($this);
     $this->tags->add($tag);
 }