src/Controller/CRUDController.php
protected function validateCsrfToken($intention)
    {
        $request = $this->getRequest();
        $token = $request->request->get('_sonata_csrf_token', false);

        if ($this->container->has('security.csrf.token_manager')) {
            $valid = $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($intention, $token));
        } else {
            return;
        }

        if (!$valid) {
            throw new HttpException(400, 'The csrf token is not valid, CSRF attack?');
        }
    }
protected function validateCsrfToken($intention)
    {
        $request = $this->getRequest();
        $token = $request->request->get('_sonata_csrf_token', false);

        if ($this->container->has('security.csrf.token_manager')) {
            $valid = $this->container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($intention, $token));
        } else {
            return;
        }

        if (!$valid) {
            throw new HttpException(400, 'The csrf token is not valid, CSRF attack?');
        }
    }
protected function validateCsrfToken ( $ intention ) { $ request = $ this -> getRequest ( ) ; $ token = $ request -> request -> get ( '_sonata_csrf_token' , false ) ; if ( $ this -> container -> has ( 'security.csrf.token_manager' ) ) { $ valid = $ this -> container -> get ( 'security.csrf.token_manager' ) -> isTokenValid ( new CsrfToken ( $ intention , $ token ) ) ; } else { return ; } if ( ! $ valid ) { throw new HttpException ( 400 , 'The csrf token is not valid, CSRF attack?' ) ; } }
Validate CSRF token for action without form.

@param string $intention

@throws HttpException
Validate CSRF token for action without form .