1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace terabytesoft\app\basic\controllers; |
4
|
|
|
|
5
|
|
|
use terabytesoft\app\basic\forms\ContactForm; |
6
|
|
|
use yii\base\Model; |
7
|
|
|
use yii\captcha\CaptchaAction; |
8
|
|
|
use yii\filters\AccessControl; |
9
|
|
|
use yii\filters\VerbFilter; |
10
|
|
|
use yii\web\Controller; |
11
|
|
|
use yii\web\ErrorAction; |
12
|
|
|
use yii\web\Response; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* SiteController |
16
|
|
|
* |
17
|
|
|
* Controller web application basic |
18
|
|
|
*/ |
19
|
|
|
class SiteController extends Controller |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
public $app; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* behaviors |
28
|
|
|
*/ |
29
|
10 |
|
public function behaviors() |
30
|
|
|
{ |
31
|
|
|
return [ |
32
|
|
|
'verbs' => [ |
33
|
10 |
|
'class' => VerbFilter::class, |
34
|
|
|
'actions' => [ |
35
|
|
|
'logout' => ['post'], |
36
|
|
|
], |
37
|
|
|
], |
38
|
|
|
]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* actions |
44
|
|
|
*/ |
45
|
10 |
|
public function actions() |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
|
|
'error' => [ |
49
|
10 |
|
'class' => ErrorAction::class, |
50
|
|
|
], |
51
|
|
|
'captcha' => [ |
52
|
|
|
'class' => CaptchaAction::class, |
53
|
10 |
|
'fixedVerifyCode' => YII_ENV ? 'testme' : null, |
54
|
|
|
], |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* actionIndex |
60
|
|
|
*/ |
61
|
1 |
|
public function actionIndex(): string |
62
|
|
|
{ |
63
|
1 |
|
return $this->render('index'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* actionAbout |
68
|
|
|
**/ |
69
|
1 |
|
public function actionAbout(): string |
70
|
|
|
{ |
71
|
1 |
|
return $this->render('about'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* actionContact |
76
|
|
|
* @return response|string |
77
|
|
|
**/ |
78
|
8 |
|
public function actionContact() |
79
|
|
|
{ |
80
|
8 |
|
$model = new ContactForm(); |
81
|
|
|
|
82
|
8 |
|
if ($model->load($this->module->request->post()) && $model->validate()) { |
|
|
|
|
83
|
2 |
|
$this->sendContact($this->module->params['app.basic.email.admin'], $model); |
84
|
2 |
|
$this->module->session->setFlash('contactFormSubmitted'); |
|
|
|
|
85
|
|
|
|
86
|
2 |
|
return $this->refresh(); |
87
|
|
|
} |
88
|
|
|
|
89
|
8 |
|
return $this->render('contact', [ |
90
|
8 |
|
'model' => $model, |
91
|
|
|
]); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* sendContact |
96
|
|
|
* @param string $email the target email address |
97
|
|
|
* @param Model $model |
98
|
|
|
**/ |
99
|
3 |
|
public function sendContact(string $email, Model $model): void |
100
|
|
|
{ |
101
|
3 |
|
$this->module->mailer->compose() |
|
|
|
|
102
|
3 |
|
->setTo($email) |
103
|
3 |
|
->setFrom( |
104
|
3 |
|
[$this->module->params['app.basic.email.admin'] => $this->module->params['app.basic.email.sendername']] |
105
|
|
|
) |
106
|
3 |
|
->setReplyTo([$model->email => $model->name]) |
107
|
3 |
|
->setSubject($model->subject) |
108
|
3 |
|
->setTextBody($model->body) |
109
|
3 |
|
->send(); |
110
|
3 |
|
} |
111
|
|
|
} |
112
|
|
|
|
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.