protected function deleteAction()
    {
        $this->dispatch(EasyAdminEvents::PRE_DELETE);

        if ('DELETE' !== $this->request->getMethod()) {
            return $this->redirect($this->generateUrl('easyadmin', ['action' => 'list', 'entity' => $this->entity['name']]));
        }

        $id = $this->request->query->get('id');
        $form = $this->createDeleteForm($this->entity['name'], $id);
        $form->handleRequest($this->request);

        if ($form->isSubmitted() && $form->isValid()) {
            $easyadmin = $this->request->attributes->get('easyadmin');
            $entity = $easyadmin['item'];

            $this->dispatch(EasyAdminEvents::PRE_REMOVE, ['entity' => $entity]);

            try {
                $this->executeDynamicMethod('remove<EntityName>Entity', [$entity, $form]);
            } catch (ForeignKeyConstraintViolationException $e) {
                throw new EntityRemoveException(['entity_name' => $this->entity['name'], 'message' => $e->getMessage()]);
            }

            $this->dispatch(EasyAdminEvents::POST_REMOVE, ['entity' => $entity]);
        }

        $this->dispatch(EasyAdminEvents::POST_DELETE);

        return $this->redirectToReferrer();
    }
protected function deleteAction()
    {
        $this->dispatch(EasyAdminEvents::PRE_DELETE);

        if ('DELETE' !== $this->request->getMethod()) {
            return $this->redirect($this->generateUrl('easyadmin', ['action' => 'list', 'entity' => $this->entity['name']]));
        }

        $id = $this->request->query->get('id');
        $form = $this->createDeleteForm($this->entity['name'], $id);
        $form->handleRequest($this->request);

        if ($form->isSubmitted() && $form->isValid()) {
            $easyadmin = $this->request->attributes->get('easyadmin');
            $entity = $easyadmin['item'];

            $this->dispatch(EasyAdminEvents::PRE_REMOVE, ['entity' => $entity]);

            try {
                $this->executeDynamicMethod('remove<EntityName>Entity', [$entity, $form]);
            } catch (ForeignKeyConstraintViolationException $e) {
                throw new EntityRemoveException(['entity_name' => $this->entity['name'], 'message' => $e->getMessage()]);
            }

            $this->dispatch(EasyAdminEvents::POST_REMOVE, ['entity' => $entity]);
        }

        $this->dispatch(EasyAdminEvents::POST_DELETE);

        return $this->redirectToReferrer();
    }
protected function deleteAction ( ) { $ this -> dispatch ( EasyAdminEvents :: PRE_DELETE ) ; if ( 'DELETE' !== $ this -> request -> getMethod ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'easyadmin' , [ 'action' => 'list' , 'entity' => $ this -> entity [ 'name' ] ] ) ) ; } $ id = $ this -> request -> query -> get ( 'id' ) ; $ form = $ this -> createDeleteForm ( $ this -> entity [ 'name' ] , $ id ) ; $ form -> handleRequest ( $ this -> request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ easyadmin = $ this -> request -> attributes -> get ( 'easyadmin' ) ; $ entity = $ easyadmin [ 'item' ] ; $ this -> dispatch ( EasyAdminEvents :: PRE_REMOVE , [ 'entity' => $ entity ] ) ; try { $ this -> executeDynamicMethod ( 'remove<EntityName>Entity' , [ $ entity , $ form ] ) ; } catch ( ForeignKeyConstraintViolationException $ e ) { throw new EntityRemoveException ( [ 'entity_name' => $ this -> entity [ 'name' ] , 'message' => $ e -> getMessage ( ) ] ) ; } $ this -> dispatch ( EasyAdminEvents :: POST_REMOVE , [ 'entity' => $ entity ] ) ; } $ this -> dispatch ( EasyAdminEvents :: POST_DELETE ) ; return $ this -> redirectToReferrer ( ) ; }
The method that is executed when the user performs a 'delete' action to
remove any entity.

@return RedirectResponse

@throws EntityRemoveException
The method that is executed when the user performs a delete action to remove any entity .