public function getLogoutUrl(Request $request, $return = null)
    {
        $logout_redirect = $this->getAttribute($request, 'logoutURL');

        if (!empty($logout_redirect)) {
            return $this->getHandlerUrl($request) . '/Logout?return='. urlencode($logout_redirect
                    . (empty($return)? '' : '?return='.$return));
        } elseif (!empty($return)) {
            return $this->getHandlerUrl($request) . '/Logout?return='.urlencode($return);
        } else {
            return $this->getHandlerUrl($request) . '/Logout';
        }
    }