src/Lokos/ShopBundle/Controller/BaseController.php
/**
     * Execute batch action and return redirect response
     *
     * @param Request $request        request object with data
     * @param string  $repositoryName repository name
     * @param string  $redirectUrl    redirect route name
     * @param array   $redirectParams additional parameters for redirect
     *
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
     */
Execute batch action and return redirect response
@param Request $request        request object with data
@param string  $repositoryName repository name
@param string  $redirectUrl    redirect route name
@param array   $redirectParams additional parameters for redirect


Execute batch action and return redirect response @param Request $request request object with data @param string $repositoryName repository name @param string $redirectUrl redirect route name @param array $redirectParams additional parameters for redirect
protected function executeBatchAction(Request $request, $repositoryName, $redirectUrl, $redirectParams = array())
    {
        $action     = $request->get('action', '');
        $id         = $request->get('id', null);
        $repository = $this->getDoctrine()
                           ->getRepository($repositoryName);
        if(!method_exists($repository, $action)){
            throw new NotFoundHttpException('Method "'.$action.'" not found for '.get_class($repository));
        }
        $result = $repository
             ->$action(
                 $this->container,
                 $id
             );
        if($result){
            $this->get('session')->getFlashBag()->add(
                'success',
                $this->translate(($action == 'remove')?'messages.successfully_removed':'messages.successfully_done')
            );
        }else{
            $this->get('session')->getFlashBag()->add('danger', $this->translate('messages.unsuccessfully_done'));
        }
        return $this->redirect($this->generateUrl($redirectUrl, $redirectParams));
    }
protected function executeBatchAction ( Request $ request , $ repositoryName , $ redirectUrl , $ redirectParams = array ( ) ) { $ action = $ request -> get ( 'action' , '' ) ; $ id = $ request -> get ( 'id' , null ) ; $ repository = $ this -> getDoctrine ( ) -> getRepository ( $ repositoryName ) ; if ( ! method_exists ( $ repository , $ action ) ) { throw new NotFoundHttpException ( 'Method "' . $ action . '" not found for ' . get_class ( $ repository ) ) ; } $ result = $ repository -> $ action ( $ this -> container , $ id ) ; if ( $ result ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , $ this -> translate ( ( $ action == 'remove' ) ? 'messages.successfully_removed' : 'messages.successfully_done' ) ) ; } else { $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'danger' , $ this -> translate ( 'messages.unsuccessfully_done' ) ) ; } return $ this -> redirect ( $ this -> generateUrl ( $ redirectUrl , $ redirectParams ) ) ; }
Execute batch action and return redirect response
 @param Request $request        request object with data
 @param string  $repositoryName repository name
 @param string  $redirectUrl    redirect route name
 @param array   $redirectParams additional parameters for redirect
Execute batch action and return redirect response @param Request $request request object with data @param string $repositoryName repository name @param string $redirectUrl redirect route name @param array $redirectParams additional parameters for redirect