private function generateLogoutUrl($key, $referenceType)
    {
        list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->getListener($key);

        if (null === $logoutPath) {
            throw new \LogicException('Unable to generate the logout URL without a path.');
        }

        $parameters = null !== $csrfTokenManager ? [$csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)] : [];

        if ('/' === $logoutPath[0]) {
            if (!$this->requestStack) {
                throw new \LogicException('Unable to generate the logout URL without a RequestStack.');
            }

            $request = $this->requestStack->getCurrentRequest();

            $url = UrlGeneratorInterface::ABSOLUTE_URL === $referenceType ? $request->getUriForPath($logoutPath) : $request->getBaseUrl().$logoutPath;

            if (!empty($parameters)) {
                $url .= '?'.http_build_query($parameters, '', '&');
            }
        } else {
            if (!$this->router) {
                throw new \LogicException('Unable to generate the logout URL without a Router.');
            }

            $url = $this->router->generate($logoutPath, $parameters, $referenceType);
        }

        return $url;
    }
private function generateLogoutUrl($key, $referenceType)
    {
        list($logoutPath, $csrfTokenId, $csrfParameter, $csrfTokenManager) = $this->getListener($key);

        if (null === $logoutPath) {
            throw new \LogicException('Unable to generate the logout URL without a path.');
        }

        $parameters = null !== $csrfTokenManager ? [$csrfParameter => (string) $csrfTokenManager->getToken($csrfTokenId)] : [];

        if ('/' === $logoutPath[0]) {
            if (!$this->requestStack) {
                throw new \LogicException('Unable to generate the logout URL without a RequestStack.');
            }

            $request = $this->requestStack->getCurrentRequest();

            $url = UrlGeneratorInterface::ABSOLUTE_URL === $referenceType ? $request->getUriForPath($logoutPath) : $request->getBaseUrl().$logoutPath;

            if (!empty($parameters)) {
                $url .= '?'.http_build_query($parameters, '', '&');
            }
        } else {
            if (!$this->router) {
                throw new \LogicException('Unable to generate the logout URL without a Router.');
            }

            $url = $this->router->generate($logoutPath, $parameters, $referenceType);
        }

        return $url;
    }
private function generateLogoutUrl ( $ key , $ referenceType ) { list ( $ logoutPath , $ csrfTokenId , $ csrfParameter , $ csrfTokenManager ) = $ this -> getListener ( $ key ) ; if ( null === $ logoutPath ) { throw new \ LogicException ( 'Unable to generate the logout URL without a path.' ) ; } $ parameters = null !== $ csrfTokenManager ? [ $ csrfParameter => ( string ) $ csrfTokenManager -> getToken ( $ csrfTokenId ) ] : [ ] ; if ( '/' === $ logoutPath [ 0 ] ) { if ( ! $ this -> requestStack ) { throw new \ LogicException ( 'Unable to generate the logout URL without a RequestStack.' ) ; } $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ url = UrlGeneratorInterface :: ABSOLUTE_URL === $ referenceType ? $ request -> getUriForPath ( $ logoutPath ) : $ request -> getBaseUrl ( ) . $ logoutPath ; if ( ! empty ( $ parameters ) ) { $ url .= '?' . http_build_query ( $ parameters , '' , '&' ) ; } } else { if ( ! $ this -> router ) { throw new \ LogicException ( 'Unable to generate the logout URL without a Router.' ) ; } $ url = $ this -> router -> generate ( $ logoutPath , $ parameters , $ referenceType ) ; } return $ url ; }
Generates the logout URL for the firewall.

@param string|null $key           The firewall key or null to use the current firewall key
@param int         $referenceType The type of reference (one of the constants in UrlGeneratorInterface)

@return string The logout URL
Generates the logout URL for the firewall .