DefaultController::actionAbout()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace modules\main\controllers;
4
5
use Yii;
6
use yii\web\Controller;
7
use yii\web\Response;
8
use modules\main\models\ContactForm;
9
10
/**
11
 * Default controller for the `main` module
12
 */
13
class DefaultController extends Controller
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    public function actions()
19
    {
20
        return [
21
            'captcha' => [
22
                'class' => 'yii\captcha\CaptchaAction',
23
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
24
            ],
25
        ];
26
    }
27
28
    /**
29
     * Renders the index view for the module
30
     * @return string
31
     */
32
    public function actionIndex()
33
    {
34
        return $this->render('index');
35
    }
36
37
    /**
38
     * Displays contact page.
39
     *
40
     * @return Response|string
41
     */
42
    public function actionContact()
43
    {
44
        $model = new ContactForm();
45
        if (Yii::$app->user->isGuest) {
46
            $model->scenario = $model::SCENARIO_GUEST;
47
        } else {
48
            $user = Yii::$app->user;
49
            /** @var \modules\users\models\User $identity */
50
            $identity = $user->identity;
51
            $model->name = $identity->username;
52
            $model->email = $identity->email;
53
        }
54
55
        if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
56
            Yii::$app->session->setFlash('contactFormSubmitted');
0 ignored issues
show
Bug introduced by
The method setFlash() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

56
            Yii::$app->session->/** @scrutinizer ignore-call */ 
57
                                setFlash('contactFormSubmitted');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
57
58
            return $this->refresh();
59
        }
60
        return $this->render('contact', [
61
            'model' => $model,
62
        ]);
63
    }
64
65
    /**
66
     * Displays about page.
67
     *
68
     * @return string
69
     */
70
    public function actionAbout()
71
    {
72
        return $this->render('about');
73
    }
74
}
75