Code Duplication    Length = 18-19 lines in 4 locations

src/ClientBundle/Controller/TagsController.php 1 location

@@ 41-59 (lines=19) @@
38
     * @Method({"GET", "POST"})
39
     * @return Response
40
     */
41
    public function newAction(Request $request)
42
    {
43
        $tag = new Tags();
44
        $form = $this->createForm('ClientBundle\Form\Type\TagsType', $tag);
45
        $form->handleRequest($request);
46
47
        if ($form->isSubmitted() && $form->isValid()) {
48
            $em = $this->getDoctrine()->getManager();
49
            $em->persist($tag);
50
            $em->flush($tag);
51
52
            return $this->redirectToRoute('tags_show', ['id' => $tag->getId()]);
53
        }
54
55
        return $this->render('ClientBundle:tags/new.html.twig', [
56
            'tag' => $tag,
57
            'form' => $form->createView(),
58
        ]);
59
    }
60
61
    /**
62
     * Finds and displays a tag entity.

src/ClientBundle/Controller/CategoryController.php 1 location

@@ 69-86 (lines=18) @@
66
     * @Method({"GET", "POST"})
67
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
68
     */
69
    public function addAction(Request $request)
70
    {
71
        $em = $this->getDoctrine()->getManager();
72
        $category = new Category();
73
        $form = $this->createForm(CategoryForm::class, $category);
74
75
        $form->handleRequest($request);
76
77
        if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
78
            $category = $form->getData();
79
            $em->persist($category);
80
            $em->flush();
81
82
            return $this->redirectToRoute('category_home');
83
        }
84
85
        return $this->render('ClientBundle:Category:edit.html.twig', ['form' => $form->createView(), 'category' => $category]);
86
    }
87
88
    /**
89
     * @param int $id

src/ClientBundle/Controller/ContactTypeController.php 1 location

@@ 68-85 (lines=18) @@
65
     * @Method({"GET", "POST"})
66
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
67
     */
68
    public function addAction(Request $request)
69
    {
70
        $em = $this->getDoctrine()->getManager();
71
        $contactType = new ContactType();
72
        $form = $this->createForm(ContactTypeForm::class, $contactType);
73
74
        $form->handleRequest($request);
75
76
        if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
77
            $contactType = $form->getData();
78
            $em->persist($contactType);
79
            $em->flush();
80
81
            return $this->redirectToRoute('contacttype_home');
82
        }
83
84
        return $this->render('ClientBundle:ContactType:edit.html.twig', ['form' => $form->createView(), 'contactType' => $contactType]);
85
    }
86
87
    /**
88
     * @param int $id

src/ClientBundle/Controller/LangController.php 1 location

@@ 68-85 (lines=18) @@
65
     * @Method({"GET", "POST"})
66
     * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
67
     */
68
    public function addAction(Request $request)
69
    {
70
        $em = $this->getDoctrine()->getManager();
71
        $lang = new Lang();
72
        $form = $this->createForm(LangForm::class, $lang);
73
74
        $form->handleRequest($request);
75
76
        if ($request->isMethod('POST') && $form->isSubmitted() && $form->isValid()) {
77
            $lang = $form->getData();
78
            $em->persist($lang);
79
            $em->flush();
80
81
            return $this->redirectToRoute('lang_home');
82
        }
83
84
        return $this->render('ClientBundle:Lang:edit.html.twig', ['form' => $form->createView(), 'lang' => $lang]);
85
    }
86
87
    /**
88
     * @param int $id