本文整理汇总了PHP中yii\web\Controller::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::redirect方法的具体用法?PHP Controller::redirect怎么用?PHP Controller::redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\web\Controller
的用法示例。
在下文中一共展示了Controller::redirect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: redirectWithMessages
/**
* @param $flag
* @param $successMessage
* @param $failedMessage
*
* @return \yii\web\Response
*/
protected function redirectWithMessages($flag, $successMessage, $failedMessage)
{
if ($flag) {
Yii::$app->session->setFlash('success', $successMessage);
return $this->controller->redirect($this->successUrl);
} else {
Yii::$app->session->setFlash('warning', $failedMessage);
return $this->controller->redirect($this->failedUrl);
}
}
示例2: beforeAction
/**
* @param \yii\base\Action $action
*/
public function beforeAction($action)
{
if ($action->controller->id == 'default') {
\yii\web\Controller::redirect('/staff/admin');
}
return true;
}
示例3: redirect
public function redirect($url, $statusCode = 302, $halt = true)
{
parent::redirect($url, $statusCode);
if ($halt) {
\Yii::$app->end($statusCode);
}
}
示例4: redirect
public function redirect($url, $force = false, $statusCode = 302)
{
$params = Yii::$app->request->queryParams;
// Meta redirect
if (headers_sent() || ob_get_contents()) {
$url = !empty($params['_return_url']) ? $params['_return_url'] : $url;
$url = Url::to($url);
$this->ech(Html::tag('meta', '', ['http-equiv' => 'Refresh', 'content' => '1;URL=' . $url . '']));
$this->ech(Html::a(__('Continue'), $url));
}
if (!empty($params['_return_url']) && !$force) {
return Yii::$app->getResponse()->redirect($params['_return_url'], $statusCode);
}
return parent::redirect($url, $statusCode);
}
示例5: dispatch
/**
* Dispatch the current controller to the getTransactionGatewayCreat link.
*
* @param \yii\web\Controller $controller The Yii controller object.
* @throws Exception
*/
public function dispatch(Controller $controller)
{
if (!$this->model) {
throw new PaymentException("Could not dispatch the controller to the requested url as the model object is empty or contains an error.");
}
$controller->redirect($this->getTransactionGatewayCreateLink());
}
示例6: redirect
/**
* Redirects and ends app. That prevents from sending additional headers.
* @inheritdoc
*/
public function redirect($url, $statusCode = 302)
{
parent::redirect($url, $statusCode);
Yii::$app->end();
}
示例7: goHome
public function goHome()
{
parent::redirect($this->homePage);
}