svyatoslav-kubakh /
postfix-admin
| 1 | <?php |
||
| 2 | namespace backend\controllers; |
||
| 3 | |||
| 4 | use Yii; |
||
| 5 | use backend\models\MailerDomain; |
||
| 6 | use backend\models\search\MailerDomainSearch; |
||
| 7 | use backend\components\Controller; |
||
| 8 | use yii\web\NotFoundHttpException; |
||
| 9 | |||
| 10 | /** |
||
| 11 | * MailerDomainController implements the CRUD actions for MailerDomain model. |
||
| 12 | * @method MailerDomain findModel($id) |
||
| 13 | */ |
||
| 14 | class MailerDomainsController extends Controller |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | protected $modelClass = MailerDomain::class; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Lists all MailerDomain models. |
||
| 23 | * @return mixed |
||
| 24 | */ |
||
| 25 | public function actionIndex() |
||
| 26 | { |
||
| 27 | $searchModel = new MailerDomainSearch(); |
||
| 28 | return $this->render('index', [ |
||
| 29 | 'dataProvider' => $searchModel |
||
| 30 | ->search(Yii::$app->request->queryParams), |
||
| 31 | ]); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Displays a single MailerDomain model. |
||
| 36 | * @param integer $id |
||
| 37 | * @return mixed |
||
| 38 | * @throws NotFoundHttpException if the model cannot be found |
||
| 39 | */ |
||
| 40 | public function actionView($id) |
||
| 41 | { |
||
| 42 | return $this->render('view', [ |
||
| 43 | 'model' => $this->findModel($id), |
||
| 44 | ]); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Creates a new MailerDomain model. |
||
| 49 | * If creation is successful, the browser will be redirected to the 'view' page. |
||
| 50 | * @return mixed |
||
| 51 | */ |
||
| 52 | public function actionCreate() |
||
| 53 | { |
||
| 54 | $model = new MailerDomain(); |
||
| 55 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 56 | return $this |
||
| 57 | ->addFlashMessage('Mailer domain created: ' . $model->name, self::FLASH_SUCCESS) |
||
| 58 | ->redirect(['view', 'id' => $model->id]); |
||
| 59 | } |
||
| 60 | return $this->render('create', [ |
||
| 61 | 'model' => $model, |
||
| 62 | ]); |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Updates an existing MailerDomain model. |
||
| 67 | * If update is successful, the browser will be redirected to the 'view' page. |
||
| 68 | * @param integer $id |
||
| 69 | * @return mixed |
||
| 70 | * @throws NotFoundHttpException if the model cannot be found |
||
| 71 | */ |
||
| 72 | public function actionUpdate($id) |
||
| 73 | { |
||
| 74 | $model = $this->findModel($id); |
||
| 75 | if ($model->load(Yii::$app->request->post()) && $model->save()) { |
||
| 76 | return $this |
||
| 77 | ->addFlashMessage('Mailer domain updated: ' . $model->name, self::FLASH_SUCCESS) |
||
| 78 | ->redirect(['view', 'id' => $model->id]); |
||
| 79 | } |
||
| 80 | return $this->render('update', [ |
||
| 81 | 'model' => $model, |
||
| 82 | ]); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * Deletes an existing MailerDomain model. |
||
| 87 | * If deletion is successful, the browser will be redirected to the 'index' page. |
||
| 88 | * @param integer $id |
||
| 89 | * @return mixed |
||
| 90 | * @throws NotFoundHttpException if the model cannot be found |
||
| 91 | */ |
||
| 92 | public function actionDelete($id) |
||
| 93 | { |
||
| 94 | $model = $this->findModel($id); |
||
| 95 | if ($model->delete()) { |
||
|
0 ignored issues
–
show
|
|||
| 96 | $this->addFlashMessage('Mailer domain deleted: ' . $model->name, self::FLASH_WARNING); |
||
| 97 | } |
||
| 98 | return $this->redirect(['index']); |
||
| 99 | } |
||
| 100 | } |
||
| 101 |
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: