Bolt\Twig\Handler\UtilsHandler::redirect PHP Method

redirect() public method

Redirect the browser to another page.
public redirect ( string $path, boolean $safe ) : string
$path string
$safe boolean
return string
    public function redirect($path, $safe)
    {
        // Nope! We're not allowing user-supplied content to issue redirects.
        if ($safe) {
            return null;
        }
        Lib::simpleredirect($path);
        return '';
    }

Usage Example

Example #1
0
 /**
  * @runInSeparateProcess
  * @requires extension xdebug
  */
 public function testRedirectNoSafe()
 {
     if (phpversion('xdebug') === false) {
         $this->markTestSkipped('No xdebug support enabled.');
     }
     $app = $this->getApp();
     $handler = new UtilsHandler($app);
     $this->expectOutputRegex('/Redirecting to/i');
     $handler->redirect('/clippy/koala', false);
     $this->assertContains('location: /clippy/koala', xdebug_get_headers());
 }