Cake\Controller\Component\AuthComponent::redirectUrl PHP Метод

redirectUrl() публичный Метод

Pass a URL in to set the destination a user should be redirected to upon logging in. If no parameter is passed, gets the authentication redirect URL. The URL returned is as per following rules: - Returns the normalized redirect URL from storage if it is present and for the same domain the current app is running on. - If there is no URL returned from storage and there is a config loginRedirect, the loginRedirect value is returned. - If there is no session and no loginRedirect, / is returned.
public redirectUrl ( string | array | null $url = null ) : string
$url string | array | null Optional URL to write as the login redirect URL.
Результат string Redirect URL
    public function redirectUrl($url = null)
    {
        if ($url !== null) {
            $redir = $url;
            $this->storage()->redirectUrl($redir);
        } elseif ($redir = $this->storage()->redirectUrl()) {
            $this->storage()->redirectUrl(false);
            if (Router::normalize($redir) === Router::normalize($this->_config['loginAction'])) {
                $redir = $this->_config['loginRedirect'];
            }
        } elseif ($this->_config['loginRedirect']) {
            $redir = $this->_config['loginRedirect'];
        } else {
            $redir = '/';
        }
        if (is_array($redir)) {
            return Router::url($redir + ['_base' => false]);
        }
        return $redir;
    }