Базовые модели перенесены в отдельное простраинство имён

Поправлены именования классов (хз, почему оно прежде работало)
This commit is contained in:
ErickSkrauch
2016-03-20 02:33:49 +03:00
parent e67257b8aa
commit 951b6928a2
12 changed files with 33 additions and 26 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace api\models\base;
use common\models\EmailActivation;
class KeyConfirmationForm extends ApiForm {
public $key;
private $model;
public function rules() {
return [
// TODO: нужно провалидировать количество попыток ввода кода для определённого IP адреса и в случае чего запросить капчу
['key', 'required', 'message' => 'error.key_is_required'],
['key', 'validateKey'],
];
}
public function validateKey($attribute) {
if (!$this->hasErrors()) {
if ($this->getActivationCodeModel() === null) {
$this->addError($attribute, "error.{$attribute}_not_exists");
}
}
}
/**
* @return EmailActivation|null
*/
public function getActivationCodeModel() {
if ($this->model === null) {
$this->model = EmailActivation::findOne($this->key);
}
return $this->model;
}
}