Code Duplication    Length = 17-20 lines in 3 locations

src/AppBundle/Controller/Admin/AdminCategoryController.php 1 location

@@ 122-139 (lines=18) @@
119
     * @Security("has_role('ROLE_ADMIN')")
120
     * @ParamConverter("estate", options={"mapping": {"slug": "slug"}})
121
     */
122
    public function categoryDeleteAction(Request $request, Category $category)
123
    {
124
        $entityManager = $this->getDoctrine()->getManager();
125
        $repo = $entityManager->getRepository('AppBundle\Entity\Category');
126
        $deleteForm = $this->createForm(CategoryType::class, $category,['method' => 'DELETE']);
127
        $deleteForm->handleRequest($request);
128
        if ($deleteForm->isSubmitted() && $deleteForm->isValid()) {
129
            $entityManager->remove($category);
130
            $repo->verify();
131
            $repo->recover();
132
            $entityManager->flush();
133
            return $this->redirectToRoute('admin_categories');
134
        }
135
        return $this->render('@App/admin/category/delete_category.html.twig', array(
136
            'category'        => $category,
137
            'delete_form'   => $deleteForm->createView(),
138
        ));
139
    }
140
141
    /**
142
     * @Route("/category/up/{slug}", name="admin_category_up")

src/AppBundle/Controller/Admin/AdminDistrictController.php 2 locations

@@ 51-70 (lines=20) @@
48
     * @Method({"GET", "POST"})
49
     * @Security("has_role('ROLE_ADMIN')")
50
     */
51
    public function newDistrictAction(Request $request)
52
    {
53
        $entityManager = $this->getDoctrine()->getManager();
54
        $district = new District();
55
        //$this->denyAccessUnlessGranted('create', $estate);
56
        $form = $this->createForm(DistrictType::class, $district)->add('saveAndCreateNew', SubmitType::class);
57
        $form->handleRequest($request);
58
        if ($form->isSubmitted() && $form->isValid()) {
59
            $entityManager->persist($district);
60
            $entityManager->flush();
61
            $nextAction = $form->get('saveAndCreateNew')->isClicked()
62
                ? 'admin_district_new'
63
                : 'admin_districts';
64
            return $this->redirectToRoute($nextAction);
65
        }
66
        return $this->render('@App/admin/district/new_district.html.twig', array(
67
            'district' => $district,
68
            'form' => $form->createView(),
69
        ));
70
    }
71
72
    /**
73
     * @Route("/district/edit/{slug}", name="admin_district_edit")
@@ 78-94 (lines=17) @@
75
     * @Security("has_role('ROLE_ADMIN')")
76
     * @ParamConverter("district", options={"mapping": {"slug": "slug"}})
77
     */
78
    public function districtEditAction(District $district, Request $request)
79
    {
80
        $entityManager = $this->getDoctrine()->getManager();
81
        $editForm = $this->createForm(DistrictType::class, $district);
82
        $deleteForm = $this->createDeleteForm($district);
83
        $editForm->handleRequest($request);
84
        if ($editForm->isSubmitted() && $editForm->isValid()) {
85
            $entityManager->persist($district);
86
            $entityManager->flush();
87
            return $this->redirectToRoute('admin_districts');
88
        }
89
        return $this->render('@App/admin/district/edit_district.html.twig', array(
90
            'district'        => $district,
91
            'edit_form'   => $editForm->createView(),
92
            'delete_form' => $deleteForm->createView(),
93
        ));
94
    }
95
96
    /**
97
     * @Route("/district/delete/{slug}", name="admin_district_delete")