Go to the documentation of this file.00001 <?php
00002
00003 namespace Admingenerated\EtraliGinangBundle\BaseCityController;
00004
00005 use Admingenerator\GeneratorBundle\Controller\Doctrine\BaseController as BaseController;
00006 use Symfony\Component\HttpFoundation\RedirectResponse;
00007
00008
00009
00010 class DeleteController extends BaseController
00011 {
00012 public function indexAction($pk)
00013 {
00014 try {
00015 $City = $this->getObject($pk);
00016
00017
00018
00019 $this->preRemove($City);
00020 $this->process($City);
00021 $this->postRemove($City);
00022
00023 $this->get('session')->setFlash('success', $this->get('translator')->trans("batch.delete.success", array(), 'Admingenerator') );
00024 } catch (\Exception $e) {
00025 $this->get('session')->setFlash('error', $this->get('translator')->trans("batch.delete.error", array(), 'Admingenerator') );
00026 $this->onException($e, $City);
00027 }
00028
00029 return new RedirectResponse($this->generateUrl("Etrali_GinangBundle_City_list"));
00030 }
00031
00032
00033
00034
00035
00036
00037
00038 public function onException(\Exception $exception, \Etrali\GinangBundle\Entity\City $City)
00039 {
00040 }
00041
00042
00043
00044
00045
00046
00047 public function preRemove(\Etrali\GinangBundle\Entity\City $City)
00048 {
00049 }
00050
00051
00052
00053
00054
00055
00056 public function postRemove(\Etrali\GinangBundle\Entity\City $City)
00057 {
00058 }
00059
00060
00061 protected function getObject($pk)
00062 {
00063 $City = $this->getDoctrine()
00064 ->getEntityManager()
00065 ->getRepository('Etrali\GinangBundle\Entity\City')
00066 ->find($pk);
00067
00068 if (!$City) {
00069 throw new \InvalidArgumentException("No Etrali\GinangBundle\Entity\City found on idCity : $pk");
00070 }
00071
00072 return $City;
00073 }
00074
00075 protected function process(\Etrali\GinangBundle\Entity\City $City)
00076 {
00077 $em = $this->getDoctrine()->getEntityManager();
00078 $em->remove($City);
00079 $em->flush();
00080 $em->clear();
00081 }
00082
00083 }