Redirector::to PHP Method

to() public method

Redirect to the given location
public to ( string $location, $query = "" )
$location string
    public function to($location, $query = "")
    {
        if (!empty($query)) {
            $query = '?' . http_build_query((array) $query, null, '&');
        }
        $response = new Response('', 302, ["Location" => $location . $query]);
        return $response;
    }

Usage Example

Exemplo n.º 1
0
 public function delete()
 {
     $todoId = Encryption::decryptIdWithDash($this->request->data("todo_id"));
     $this->todo->delete($todoId);
     // in case of normal post request
     Session::set('success', "Todo has been deleted");
     Redirector::to(PUBLIC_ROOT . "Todo");
     // in case of ajax
     // echo $this->view->JSONEncode(array("success" => "Todo has been deleted"));
 }
All Usage Examples Of Redirector::to