本文整理匯總了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);