Advertisement
Guest User

Untitled

a guest
Jan 14th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. public function deleteAction()
  2.     {
  3.         $id = (int)$this->getEvent()->getRouteMatch()->getParam('id');
  4.         if (!$id) {
  5.             return $this->redirect()->toRoute('album');
  6.         }
  7.        
  8.         $request = $this->getRequest();
  9.         if ($request->isPost()) {
  10.             $del = $request->getPost()->get('del', 'No');
  11.             if ($del == 'Yes') {
  12.                 $id = (int)$request->getPost()->get('id');
  13.                 $album = $this->getEntityManager()->find('Album\Entity\Album', $id);
  14.                 if ($album) {
  15.                     $this->getEntityManager()->remove($album);
  16.                     $this->getEntityManager()->flush();
  17.                 }
  18.             }
  19.            
  20.             // Redirect to list of albums
  21.             return $this->redirect()->toRoute('album', array(
  22.                 'controller' => 'album',
  23.                 'action'     => 'delete',
  24.                 ));
  25.         }
  26.        
  27.         return array(
  28.             'id' => $id,
  29.             'album' => $this->getEntityManager()->find('Album\Entity\Album', $id)->getArrayCopy()
  30.             );
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement