denyAccessUnlessGranted('geofence.list', null, 'No access.'); $params['areas'] = $this->getDoctrine() ->getRepository(SupportedArea::class) ->findAll();; return $this->render('geofence/list.html.twig', $params); } /** * @Menu(selected="geofence_list") */ public function addForm() { $this->denyAccessUnlessGranted('geofence.add', null, 'No access.'); $params['obj'] = new SupportedArea(); // response return $this->render('geofence/form.html.twig', $params); } public function uploadKML(Request $req, FileUploader $uploader, KMLFileImporter $importer) { // retrieve temporary info for file $file = $req->files->get('kml_file'); // upload the file $filename = $uploader->upload($file); // process the kml file $kml_file = $uploader->getTargetDir() . '/' . $filename; $importer->getMapdata($kml_file); // return response return $this->json([ 'success' => true, 'filename' => $filename ]); } public function destroy($id) { $this->denyAccessUnlessGranted('geofence.delete', null, 'No access.'); // get object data $em = $this->getDoctrine()->getManager(); $obj = $em->getRepository(SupportedArea::class)->find($id); if (empty($obj)) throw $this->createNotFoundException('The item does not exist'); // delete this object $em->remove($obj); $em->flush(); // response $response = new Response(); $response->setStatusCode(Response::HTTP_OK); $response->send(); } }