FOF30\Controller\Controller::setRedirect PHP Method

setRedirect() public method

Set a URL for browser redirection.
public setRedirect ( string $url, string $msg = null, string $type = null ) : Controller
$url string URL to redirect to.
$msg string Message to display on redirect. Optional, defaults to value set internally by controller, if any.
$type string Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage.
return Controller This object to support chaining.
    public function setRedirect($url, $msg = null, $type = null)
    {
        // If we're parsing a non-SEF URL decide whether to use JRoute or not
        if (strpos($url, 'index.php') === 0) {
            $isAdmin = $this->container->platform->isBackend();
            $auto = false;
            if (($this->autoRouting == 2 || $this->autoRouting == 3) && $isAdmin) {
                $auto = true;
            }
            if (($this->autoRouting == 1 || $this->autoRouting == 3) && !$isAdmin) {
                $auto = true;
            }
            if ($auto) {
                $url = \JRoute::_($url, false);
            }
        }
        // Set the redirection
        $this->redirect = $url;
        if ($msg !== null) {
            // Controller may have set this directly
            $this->message = $msg;
        }
        // Ensure the type is not overwritten by a previous call to setMessage.
        if (empty($this->messageType)) {
            $this->messageType = 'message';
        }
        // If the type is explicitly set, set it.
        if (!empty($type)) {
            $this->messageType = $type;
        }
        return $this;
    }