Beispiel #1
0
 /**
  * @Route("/insert/tag", name="insert_tag")
  */
 public function insertTagAction(Request $request)
 {
     $tag = new Tag();
     $tag->setAdded(new \DateTime('now'));
     $tag->setAdminId($this->getUser()->getId());
     $form = $this->createForm(TagType::class, $tag);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($tag);
         $em->flush();
         return $this->redirectToRoute('insert_tag');
     }
     $repository = $this->getDoctrine()->getRepository('AppBundle:Tag');
     $tags = $repository->findAll();
     return $this->render('tag/insert.html.twig', array('form' => $form->createView(), 'tags' => $tags));
 }