Commit 9c8927b0 authored by Shakarim Sapa's avatar Shakarim Sapa

- Изменен родительский класс active record. Добавлен новый валидатор (пока что не отлаженый)

parent e2fde3a9
......@@ -21,10 +21,17 @@ use common\modules\users\models\User;
* @property TriggerConnection[] $triggerConnections
* @property User $owner
*/
class TriggerTrigger extends \yii\db\ActiveRecord
class TriggerTrigger extends \common\components\ActiveRecordModel
{
const PAGE_SIZE = 10;
public $conditions = [];
public function name()
{
return 'Триггеры';
}
/**
* @inheritdoc
*/
......@@ -33,6 +40,11 @@ class TriggerTrigger extends \yii\db\ActiveRecord
return 'trigger_trigger';
}
public function behaviors()
{
return [];
}
/**
* @inheritdoc
*/
......@@ -40,14 +52,26 @@ class TriggerTrigger extends \yii\db\ActiveRecord
{
return [
[['active', 'owner_id', 'timeout', 'message_template_id'], 'integer'],
[['name', 'owner_id'], 'required'],
[['name', 'owner_id', 'timeout'], 'required'],
[['description'], 'string'],
[['date_create'], 'safe'],
[['name'], 'string', 'max' => 255],
[['conditions'], function($attribute, $params) {
$this->addError($attribute, 'asd');
}],
[['owner_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['owner_id' => 'id']],
];
}
// public function checkConditions($attribute, $params){
// var_dump('asd'); die;
// if (!is_array($this->$attribute) || count($this->$attribute)===0) {
// $this->addError($attribute, 'Conditions is empty or has a wrong format');
// return false;
// }
// return false;
// }
/**
* @inheritdoc
*/
......@@ -62,7 +86,7 @@ class TriggerTrigger extends \yii\db\ActiveRecord
'date_create' => 'Дата создания',
'timeout' => 'Задержка перед выполнением (секунд)',
'message_template_id' => 'Шаблон письма',
'conditions' => 'Шаблон письма',
'conditions' => 'Условия',
];
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment