1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace andmemasin\emailsvalidator\controllers; |
4
|
|
|
|
5
|
|
|
use andmemasin\emailsvalidator\models\EmailsValidationForm; |
6
|
|
|
use andmemasin\emailsvalidator\Module; |
7
|
|
|
use Yii; |
8
|
|
|
use yii\data\ArrayDataProvider; |
9
|
|
|
use yii\i18n\Formatter; |
10
|
|
|
use yii\web\Controller; |
11
|
|
|
use yii\filters\AccessControl; |
12
|
|
|
|
13
|
|
|
class SiteController extends Controller |
14
|
|
|
{ |
15
|
|
|
/** @var Module */ |
16
|
|
|
public $module; |
17
|
|
|
|
18
|
|
|
public function init() |
19
|
|
|
{ |
20
|
|
|
$this->module = \Yii::$app->getModule('emailsvalidator'); |
21
|
|
|
parent::init(); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function behaviors() |
25
|
|
|
{ |
26
|
|
|
return [ |
27
|
|
|
'access' => [ |
28
|
|
|
'class' => AccessControl::class, |
29
|
|
|
'rules' => [ |
30
|
|
|
[ |
31
|
|
|
'actions' => ['index'], |
32
|
|
|
'allow' => true, |
33
|
|
|
'roles' => [$this->module->accessPermissionName], |
34
|
|
|
], |
35
|
|
|
], |
36
|
|
|
], |
37
|
|
|
|
38
|
|
|
]; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return mixed |
43
|
|
|
*/ |
44
|
|
|
public function actionIndex() |
45
|
|
|
{ |
46
|
|
|
|
47
|
|
|
/** @var EmailsValidationForm $model */ |
48
|
|
|
$model = new EmailsValidationForm(); |
49
|
|
|
$dataProvider = null; |
50
|
|
|
|
51
|
|
|
if($model->load(Yii::$app->request->post()) && $model->process()){ |
52
|
|
|
$dataProvider = new ArrayDataProvider([ |
53
|
|
|
'allModels'=>($model->displayOnlyProblems ? $model->failingEmailAddresses:$model->emailAddresses), |
54
|
|
|
'pagination' => [ |
55
|
|
|
'pageSize' => count($model->emailAddresses), |
56
|
|
|
], |
57
|
|
|
]); |
58
|
|
|
$formatter = new Formatter(); |
59
|
|
|
|
60
|
|
|
if(!empty($model->failingEmailAddresses)){ |
61
|
|
|
Yii::$app->session->addFlash('danger',Yii::t('app','There were {count} e-mail addresses that failed validation!',[ |
|
|
|
|
62
|
|
|
'count'=>count($model->failingEmailAddresses) |
63
|
|
|
])); |
64
|
|
|
} |
65
|
|
|
Yii::$app->session->addFlash('success',Yii::t('app','Checked {count} e-mails in {duration}!',[ |
66
|
|
|
'count'=>count($model->emailAddresses), |
67
|
|
|
'duration'=>$formatter->asDuration(Yii::getLogger()->getElapsedTime()) |
68
|
|
|
])); |
69
|
|
|
} |
70
|
|
|
return $this->render('index', [ |
71
|
|
|
'model'=>$model, |
72
|
|
|
'dataProvider'=>$dataProvider, |
73
|
|
|
]); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
} |
78
|
|
|
|
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.