本文整理汇总了PHP中redirect::home方法的典型用法代码示例。如果您正苦于以下问题:PHP redirect::home方法的具体用法?PHP redirect::home怎么用?PHP redirect::home使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类redirect
的用法示例。
在下文中一共展示了redirect::home方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirect
/**
* Redirect to a specific page.
*
* @param string $target Page to redirect to.
* @param array $data Optional data to save in a users session.
*/
protected function redirect($target, $data = null)
{
// Write optional session data
if ($data instanceof Messages) {
Session::flash('errors', $data->toArray());
} else {
if (is_array($data)) {
Session::flash($data);
} else {
if (!is_null($data)) {
Session::flash('data', $data);
}
}
}
// Allow to specify the redirect uri as parameter
$url = r::get('redirect_to');
if (!empty($url)) {
redirect::to($url);
}
// Perform redirect
switch ($target) {
case 'home':
redirect::home();
break;
case 'back':
redirect::back();
break;
case '404':
$page = site()->errorPage();
redirect::to($page->uri());
break;
case 'referer':
$referer = server::get('HTTP_REFERER');
redirect::to($referer);
break;
default:
redirect::to($target);
break;
}
}
示例2: array
/**
* Plugin Filters
*
* Allows to register filters that can be used to run application logic just
* before a route action is executed.
*
* @see CommentPlugin::routes()
* @var array
*/
return array('auth' => function () {
if (!user::current() || !user::current()->isAdmin()) {
redirect::to('plugin/comments/wizard');
}
}, 'installed' => function () {
if ($this->isInstalled()) {
redirect::home();
}
}, 'userCanCreate' => function () {
$route = plugin('comments')->route();
$hash = a::first($route->arguments());
$page = site()->index()->findBy('hash', $hash);
return $page instanceof Page && $page->isVisible();
}, 'userCanRead' => function () {
$route = plugin('comments')->route();
$hash = a::first($route->arguments());
$page = site()->index()->findBy('hash', $hash);
return $page instanceof Page && $page->isVisible();
}, 'userCanUpdate' => function () {
$route = plugin('comments')->route();
$id = a::last($route->arguments());
$comment = comment::find($id);