svyatoslav-kubakh /
postfix-admin
| 1 | <?php |
||
| 2 | namespace backend\controllers; |
||
| 3 | |||
| 4 | use Yii; |
||
| 5 | use backend\models\MailerAlias; |
||
| 6 | use backend\models\MailerDomain; |
||
| 7 | use backend\models\search\MailerAliasSearch; |
||
| 8 | use backend\components\Controller; |
||
| 9 | use yii\web\NotFoundHttpException; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * MailerAliasesController implements the CRUD actions for MailerAlias model. |
||
| 13 | * @method MailerAlias findModel($id) |
||
| 14 | */ |
||
| 15 | class MailerAliasesController extends Controller |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $modelClass = MailerAlias::class; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Lists all MailerAlias models. |
||
| 24 | * @return mixed |
||
| 25 | */ |
||
| 26 | public function actionIndex() |
||
| 27 | { |
||
| 28 | $searchModel = new MailerAliasSearch(); |
||
| 29 | return $this->render('index', [ |
||
| 30 | 'searchModel' => $searchModel, |
||
| 31 | 'dataProvider' => $searchModel |
||
| 32 | ->search(Yii::$app->request->queryParams), |
||
| 33 | ]); |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Displays a single MailerAlias model. |
||
| 38 | * @param integer $id |
||
| 39 | * @return mixed |
||
| 40 | * @throws NotFoundHttpException if the model cannot be found |
||
| 41 | */ |
||
| 42 | public function actionView($id) |
||
| 43 | { |
||
| 44 | return $this->render('view', [ |
||
| 45 | 'model' => $this->findModel($id), |
||
| 46 | ]); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Creates a new MailerAlias model. |
||
| 51 | * If creation is successful, the browser will be redirected to the 'view' page. |
||
| 52 | * @return mixed |
||
| 53 | */ |
||
| 54 | public function actionCreate() |
||
| 55 | { |
||
| 56 | $model = new MailerAlias(); |
||
| 57 | |||
| 58 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 59 | return $this |
||
| 60 | ->addFlashMessage('Mailer alias created: ' . $model, self::FLASH_SUCCESS) |
||
| 61 | ->redirect(['view', 'id' => $model->id]); |
||
| 62 | } |
||
| 63 | |||
| 64 | return $this->render('create', [ |
||
| 65 | 'model' => $model, |
||
| 66 | ]); |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Updates an existing MailerAlias model. |
||
| 71 | * If update is successful, the browser will be redirected to the 'view' page. |
||
| 72 | * @param integer $id |
||
| 73 | * @return mixed |
||
| 74 | * @throws NotFoundHttpException if the model cannot be found |
||
| 75 | */ |
||
| 76 | public function actionUpdate($id) |
||
| 77 | { |
||
| 78 | $model = $this->findModel($id); |
||
| 79 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 80 | return $this |
||
| 81 | ->addFlashMessage('Mailer alias updated: ' . $model, self::FLASH_SUCCESS) |
||
| 82 | ->redirect(['view', 'id' => $model->id]); |
||
| 83 | } |
||
| 84 | return $this->render('update', [ |
||
| 85 | 'model' => $model, |
||
| 86 | ]); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Deletes an existing MailerAlias model. |
||
| 91 | * If deletion is successful, the browser will be redirected to the 'index' page. |
||
| 92 | * @param integer $id |
||
| 93 | * @return mixed |
||
| 94 | * @throws NotFoundHttpException if the model cannot be found |
||
| 95 | */ |
||
| 96 | public function actionDelete($id) |
||
| 97 | { |
||
| 98 | $model = $this->findModel($id); |
||
| 99 | if ($model->delete()) { |
||
|
0 ignored issues
–
show
|
|||
| 100 | $this->addFlashMessage('Mailer alias deleted: ' . $model, self::FLASH_WARNING); |
||
| 101 | } |
||
| 102 | return $this->redirect(['index']); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @inheritdoc |
||
| 107 | */ |
||
| 108 | public function render($view, $params = []) |
||
| 109 | { |
||
| 110 | return parent::render($view, $params + [ |
||
| 111 | 'domainsList' => MailerDomain::find() |
||
| 112 | ->getListValues(), |
||
| 113 | ]); |
||
| 114 | } |
||
| 115 | } |
||
| 116 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
integervalues, zero is a special case, in particular the following results might be unexpected: