src/Tomahawk/Bundle/CSRFBundle/EventListener/TokenListener.php
public function onRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        // Does this request require CSRF protection
        if (true !== $request->get('filter_csrf')) {
            return;
        }

        $postedToken = $request->get($this->tokenManager->getTokenName());
        $actualToken = $this->tokenManager->getToken();

        // Check if token is set
        if ('POST' === $request->getMethod() && !$postedToken) {
            throw new TokenNotFoundException();
        }
        // Check if token is valid
        else if ('POST' === $request->getMethod()
            && $postedToken !== $actualToken) {
            throw new InvalidTokenException();
        }
    }
public function onRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();

        // Does this request require CSRF protection
        if (true !== $request->get('filter_csrf')) {
            return;
        }

        $postedToken = $request->get($this->tokenManager->getTokenName());
        $actualToken = $this->tokenManager->getToken();

        // Check if token is set
        if ('POST' === $request->getMethod() && !$postedToken) {
            throw new TokenNotFoundException();
        }
        // Check if token is valid
        else if ('POST' === $request->getMethod()
            && $postedToken !== $actualToken) {
            throw new InvalidTokenException();
        }
    }
KernelEvents::REQUEST event listener

@param GetResponseEvent $event
@throws InvalidTokenException
@throws TokenNotFoundException