mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 07:03:35 +08:00
Implement helper method for redirecting
This commit is contained in:
parent
69038857fa
commit
fd2ee008fa
|
@ -1,7 +1,8 @@
|
||||||
<?php namespace Flarum\Support;
|
<?php namespace Flarum\Support;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Contracts\Bus\Dispatcher;
|
use Illuminate\Contracts\Bus\Dispatcher;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
use Zend\Diactoros\Response;
|
||||||
|
|
||||||
abstract class Action
|
abstract class Action
|
||||||
{
|
{
|
||||||
|
@ -18,4 +19,26 @@ abstract class Action
|
||||||
$action = app($class);
|
$action = app($class);
|
||||||
return $action->call($params);
|
return $action->call($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $url
|
||||||
|
* @return \Psr\Http\Message\ResponseInterface
|
||||||
|
*/
|
||||||
|
protected function redirectTo($url)
|
||||||
|
{
|
||||||
|
$content = sprintf('<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="refresh" content="1;url=%1$s" />
|
||||||
|
|
||||||
|
<title>Redirecting to %1$s</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Redirecting to <a href="%1$s">%1$s</a>.
|
||||||
|
</body>
|
||||||
|
</html>', htmlspecialchars($url, ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
|
return new Response($content, 302, ['location' => $url]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user