Dominus77 /
yii2-maintenance
| 1 | <?php |
||
| 2 | |||
| 3 | namespace dominus77\maintenance\actions\frontend; |
||
| 4 | |||
| 5 | use Yii; |
||
| 6 | use yii\base\Action; |
||
| 7 | use yii\web\Response; |
||
| 8 | use yii\web\Session; |
||
| 9 | use dominus77\maintenance\models\SubscribeForm; |
||
| 10 | use dominus77\maintenance\BackendMaintenance; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class SubscribeAction |
||
| 14 | * @package dominus77\maintenance\actions\frontend |
||
| 15 | */ |
||
| 16 | class SubscribeAction extends Action |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @return Response |
||
| 20 | */ |
||
| 21 | public function run() |
||
| 22 | { |
||
| 23 | $model = new SubscribeForm(); |
||
| 24 | $msgSuccess = BackendMaintenance::t('app', 'We will inform you when everything is ready!'); |
||
| 25 | $msgInfo = BackendMaintenance::t('app', 'You have already subscribed to the alert!'); |
||
| 26 | if (($post = Yii::$app->request->post()) && $model->load($post) && $model->validate()) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 27 | /** @var Session $session */ |
||
| 28 | $session = Yii::$app->session; |
||
| 29 | if ($model->subscribe()) { |
||
| 30 | $session->setFlash($model::SUBSCRIBE_SUCCESS, $msgSuccess); |
||
| 31 | } else { |
||
| 32 | $session->setFlash($model::SUBSCRIBE_INFO, $msgInfo); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | return $this->controller->redirect(Yii::$app->request->referrer); |
||
| 36 | } |
||
| 37 | } |
||
| 38 |