/** * Sends redirect headers. * * Note that this will not end script execution! * * @param array|string $target array query params or absolute url as string * @param string $file file to which redirect * @todo set http response code to 302/303. * * @returns void */ public function redirect($target = array(), $file = 'fajr.php') { Preconditions::check(is_array($target) || is_string($target), '$target needs to be array or string'); if (is_array($target)) { $url = FajrUtils::buildUrl($target, $file); } else { if (is_string($target)) { $url = $target; } else { assert(false); } } // Note: It is tempting to end script execution here. // However, it is not wise. Calling exit() will start // php shutdown phase and according to manual // there is unpredictable object destruction order // in this phase header('Location: ' . $url); $this->set('redirectUrl', $url); $this->setTemplate('redirect'); }