| @@ 102-113 (lines=12) @@ | ||
| 99 | * @Security("has_role('ROLE_ADMIN')") |
|
| 100 | * @ParamConverter("district", options={"mapping": {"slug": "slug"}}) |
|
| 101 | */ |
|
| 102 | public function DistrictDeleteAction(Request $request, District $district) |
|
| 103 | { |
|
| 104 | $form = $this->createDeleteForm($district); |
|
| 105 | $form->handleRequest($request); |
|
| 106 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 107 | $entityManager = $this->getDoctrine()->getManager(); |
|
| 108 | ||
| 109 | $entityManager->remove($district); |
|
| 110 | $entityManager->flush(); |
|
| 111 | } |
|
| 112 | return $this->redirectToRoute('admin_districts'); |
|
| 113 | } |
|
| 114 | ||
| 115 | private function createDeleteForm(District $district) |
|
| 116 | { |
|
| @@ 133-144 (lines=12) @@ | ||
| 130 | * @Security("is_granted('remove', estate)") |
|
| 131 | * @ParamConverter("estate", options={"mapping": {"slug": "slug"}}) |
|
| 132 | */ |
|
| 133 | public function estateDeleteAction(Request $request, Estate $estate) |
|
| 134 | { |
|
| 135 | $this->denyAccessUnlessGranted('remove', $estate); |
|
| 136 | //$cacheManager = $this->container->get('liip_imagine.cache.manager'); |
|
| 137 | $form = $this->createDeleteForm($estate); |
|
| 138 | $form->handleRequest($request); |
|
| 139 | if ($form->isSubmitted() && $form->isValid()) { |
|
| 140 | $entityManager = $this->getDoctrine()->getManager(); |
|
| 141 | $entityManager->remove($estate); |
|
| 142 | //$cacheManager->remove(); |
|
| 143 | $entityManager->flush(); |
|
| 144 | } |
|
| 145 | return $this->redirectToRoute('admin_estates'); |
|
| 146 | } |
|
| 147 | ||