示例#1
0
 public function rules()
 {
     return [[['createdByAttribute', 'updatedByAttribute'], 'blameable'], [['createdAtAttribute', 'updatedAtAttribute'], 'timestampValidator'], [['slugAttribute'], 'sluggableValidator'], [['langClassSuffix', 'alias'], 'safe'], [['userTable', 'attribute', 'pathAttribute', 'baseUrlAttribute', 'name'], 'match', 'pattern' => '/^([\\w ]+\\.)?([\\w\\* ]+)$/', 'message' => 'Only word characters, and optionally spaces, an asterisk and/or a dot are allowed.'], [['immutable'], BooleanValidator::className()], [['attribute', 'pathAttribute', 'baseUrlAttribute'], 'uploadValidation'], [['createdAtAttribute', 'updatedAtAttribute', 'createdByAttribute', 'updatedByAttribute'], 'string', 'max' => 255], [['phoneAttribute'], 'phoneValidate'], [['langForeignKey'], 'langField'], [['dynamicLangClass'], DefaultValueValidator::className(), 'value' => function ($value, $model, $attribute = null) {
         return $this->class || $this->tableName ? true : null;
     }], [['abridge'], DefaultValueValidator::className(), 'value' => function ($value, $model, $attribute = null) {
         return $this->class || $this->tableName ? false : null;
     }], [['requireTranslations'], DefaultValueValidator::className(), 'value' => function ($value, $model, $attribute = null) {
         return $this->class || $this->tableName ? false : null;
     }], [['tableName', 'class'], 'classValid'], [['languageField'], DefaultValueValidator::className(), 'value' => function ($value, $model, $attribute = null) {
         return $this->class || $this->tableName ? 'language' : $value;
     }], [['attributesLang'], DefaultValueValidator::className(), 'value' => function () {
         $this->class || $this->tableName ? [new Field(['name' => 'title', 'type' => Schema::TYPE_STRING, 'length' => 500, 'comment' => 'Title']), new Field(['name' => 'body', 'type' => Schema::TYPE_TEXT, 'comment' => 'Body']), new Field(['name' => 'slug', 'type' => Schema::TYPE_STRING, 'length' => 2000, 'comment' => 'Slug'])] : null;
     }]];
 }