Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @Route("/delete/{id}", name="ci_item_delete", requirements={"id"="d+"}, options={"expose"=true})
- * @Security("has_role('ROLE_USER') && is_granted('delete', item)")
- * @param Request $request
- * @param Item $item
- * @return RedirectResponse
- */
- public function deleteAction(Request $request, Item $item)
- {
- $referer = $request
- ->headers
- ->get('referer');
- $rpath = parse_url($referer, PHP_URL_PATH );
- $badreferrers = array(
- $this->generateUrl('ci_item_show', ['id' => $item->getId()]),
- $this->generateUrl('ci_item_edit', ['id' => $item->getId()])
- );
- if(in_array($rpath, $badreferrers) ){ //coming from a page that won't exist once the Item is deleted
- $redirect = $this->generateUrl('ci_item_list_format_room', ['format_id'=> $item->getFormat()->getId(), 'room_id'=> $item->getRoom()->getId()]);
- } else {
- $redirect = $referer;
- }
- $em = $this->getDoctrine()->getManager();
- $em->remove($item);
- $em->flush();
- $this->addFlash('success', 'msg.delete.item.success');
- return $this->redirect($redirect);
- }
- /**
- * @Route("/delete/{id}", name="ci_item_delete", requirements={"id"="d+"}, options={"expose"=true})
- * @Route("/deletefromlist/{id}", name="ci_item_delete_from_list", requirements={"id"="d+"}, options={"expose"=true})
- * @Security("has_role('ROLE_USER') && is_granted('delete', item)")
- * @param Request $request
- * @param Item $item
- * @return RedirectResponse
- */
- public function deleteAction(Request $request, Item $item)
- {
- $referer = $request
- ->headers
- ->get('referer');
- if($request->get('_route') == 'ci_item_delete' ){ //coming from a page that won't exist once the Item is deleted
- $redirect = $this->generateUrl('ci_item_list_format_room', ['format_id'=> $item->getFormat()->getId(), 'room_id'=> $item->getRoom()->getId()]);
- } else {
- $redirect = $referer;
- }
- $em = $this->getDoctrine()->getManager();
- $em->remove($item);
- $em->flush();
- $this->addFlash('success', 'msg.delete.item.success');
- return $this->redirect($redirect);
- }
Add Comment
Please, Sign In to add comment