本文整理汇总了PHP中common\widgets\Alert::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Alert::add方法的具体用法?PHP Alert::add怎么用?PHP Alert::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\widgets\Alert
的用法示例。
在下文中一共展示了Alert::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex($url)
{
$model = Page::findOne(['url' => $url]);
if (!$model) {
Alert::add('Strona nie została znaleziona', Alert::TYPE_ERROR);
return $this->goHome();
}
return $this->render('index', ['model' => $model]);
}
示例2: actionIndex
/**
* @param string $url
* @return string
*/
public function actionIndex($url)
{
$model = Group::findOne(['url' => $url]);
if (!$model) {
Alert::add(Yii::t('msg', 'Page not found.'), Alert::TYPE_ERROR);
return $this->goHome();
}
return $this->render('index', ['model' => $model]);
}
示例3: actionUpdate
public function actionUpdate($id = null)
{
/** @var User $model */
$model = User::findOne(Yii::$app->user->getIdentity()->id);
$model->setScenario('update');
if ($model->load(Yii::$app->request->post())) {
if ($model->newPassword) {
$model->setPassword($model->newPassword);
}
if ($model->save()) {
Alert::add(Yii::t('msg', 'Operation completed successfully.'));
}
}
return $this->render('update', ['model' => $model]);
}
示例4: actionResetPassword
/**
* Resets password.
*
* @param string $token
* @return mixed
* @throws BadRequestHttpException
*/
public function actionResetPassword($token)
{
try {
$model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
throw new BadRequestHttpException($e->getMessage());
}
if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) {
Alert::add(Yii::t('msg', 'New password was saved. Now you can log in.'));
return $this->goHome();
}
return $this->render('resetPassword', ['model' => $model]);
}