public function phoneValidate()
 {
     if ($this->class == PhoneInputBehavior::className()) {
         if (!preg_match('/^([\\w ]+\\.)?([\\w\\* ]+)$/', $this->phoneAttribute) || empty($this->phoneAttribute)) {
             $this->addError('phoneAttribute', 'Phone attribute name must be defined');
         }
     }
 }
 public function predefineBehaviors()
 {
     return ['bleamble' => ['checked' => false, 'title' => 'Blameable behavior', 'alias' => 'bleamble', 'updatedByAttribute' => ['name' => 'updater_id', 'type' => Schema::TYPE_INTEGER, 'comment' => 'Updater', 'related_table' => 'user', 'related_field' => 'id'], 'createdByAttribute' => ['name' => 'author_id', 'type' => Schema::TYPE_INTEGER, 'related_table' => 'user', 'related_field' => 'id', 'comment' => 'Author'], 'class' => BlameableBehavior::className(), 'userTable' => 'user'], 'timestamp' => ['checked' => false, 'alias' => 'timestamp', 'title' => 'Timestamp behavior', 'createdAtAttribute' => ['name' => 'created_at', 'type' => Schema::TYPE_INTEGER, 'length' => 20, 'comment' => 'Created At'], 'updatedAtAttribute' => ['name' => 'updated_at', 'type' => Schema::TYPE_INTEGER, 'length' => 20, 'comment' => 'Updated At'], 'class' => TimestampBehavior::className()], 'sluggable' => ['alias' => 'sluggable', 'checked' => false, 'title' => 'Sluggable behavior', 'slugAttribute' => ['name' => 'slug', 'type' => Schema::TYPE_STRING, 'comment' => 'Slug', 'length' => 2000], 'attribute' => ['name' => 'attribute', 'type' => Schema::TYPE_STRING, 'comment' => 'Base Attribute', 'length' => 2000], 'immutable' => true, 'class' => SluggableBehavior::className()], 'upload' => ['alias' => 'upload', 'checked' => false, 'title' => 'Upload behavior', 'pathAttribute' => ['name' => 'photo_path', 'type' => Schema::TYPE_STRING, 'length' => 1024, 'comment' => 'Photo path'], 'baseUrlAttribute' => ['name' => 'photo_url', 'type' => Schema::TYPE_STRING, 'length' => 1024, 'comment' => 'Photo url'], 'class' => UploadBehavior::className(), 'attribute' => 'photo'], 'phone' => ['alias' => 'phone', 'checked' => false, 'title' => 'Phone behavior', 'phoneAttribute' => ['name' => 'phone', 'type' => Schema::TYPE_INTEGER, 'length' => 20, 'comment' => 'Phone'], 'class' => PhoneInputBehavior::className()]];
 }
 /**
  * @param ActiveRecord $model
  */
 protected function excludeField($model, $addition = '')
 {
     $this->fieldExclude = ArrayHelper::merge(is_array($this->excludedField) ? $this->excludedField : [$this->excludedField], $this->fieldExclude);
     if (is_callable($this->excludeFieldCallback)) {
         $func = $this->excludeFieldCallback;
         $result = $func($this);
         $result = $result ? is_array($result) ? $result : [$result] : [];
         $this->fieldExclude = ArrayHelper::merge($this->fieldExclude, $result);
     }
     $this->fieldExclude = ArrayHelper::merge($this->fieldExclude, $model->getTableSchema()->primaryKey);
     $behaviors = $model->getBehaviors();
     foreach ($behaviors as $_next) {
         $_nextCopy = $_next;
         $_next = (array) $_next;
         $_next['class'] = $_nextCopy->className();
         if ($_next['class'] === BlameableBehavior::className()) {
             if (isset($_next['updatedByAttribute'])) {
                 if (!empty($_next['updatedByAttribute'])) {
                     $this->fieldExclude[] = $addition . $_next['updatedByAttribute'];
                 }
             } else {
                 $this->fieldExclude[] = $addition . 'updated_by';
             }
             if (isset($_next['createdByAttribute'])) {
                 if (!empty($_next['createdByAttribute'])) {
                     $this->fieldExclude[] = $addition . $_next['createdByAttribute'];
                 }
             } else {
                 $this->fieldExclude[] = $addition . 'created_by';
             }
         } else {
             if ($_next['class'] === TimestampBehavior::className()) {
                 if (isset($_next['updatedAtAttribute'])) {
                     if (!empty($_next['updatedAtAttribute'])) {
                         $this->fieldExclude[] = $addition . $_next['updatedAtAttribute'];
                     }
                 } else {
                     $this->fieldExclude[] = $addition . 'updated_at';
                 }
                 if (isset($_next['createdAtAttribute'])) {
                     if (!empty($_next['createdAtAttribute'])) {
                         $this->fieldExclude[] = $addition . $_next['createdAtAttribute'];
                     }
                 } else {
                     $this->fieldExclude[] = $addition . 'created_at';
                 }
             } else {
                 if ($_next['class'] === PhoneInputBehavior::className()) {
                     if (!$this->searchColumn($_next['phoneAttribute'])) {
                         $this->columns[] = new WidgetsCrud(['fieldName' => $_next['phoneAttribute'], 'widgetType' => 'phone']);
                     }
                 } else {
                     if ($_next['class'] === UploadBehavior::className()) {
                         if (!is_array($this->hasUploadBehavior)) {
                             $this->hasUploadBehavior = ['attributes' => []];
                         }
                         $this->hasUploadBehavior['attributes'][] = isset($_next['attribute']) ? $_next['attribute'] : $_next['attribute'];
                         $this->hasUploadBehavior[] = $_next['pathAttribute'];
                         $this->hasUploadBehavior[] = $_next['baseUrlAttribute'];
                         $this->fieldExclude[] = $addition . $_next['pathAttribute'];
                         $this->fieldExclude[] = $addition . $_next['baseUrlAttribute'];
                         if (!$this->searchColumn($this->hasUploadBehavior)) {
                             $this->columns[] = new WidgetsCrud(['fieldName' => $addition . $_next['attribute'], 'widgetType' => 'upload']);
                         }
                         if (isset($this->columnUsed['upload']) && ($uses = $this->columnUsed['upload'])) {
                             if (isset($uses['expression'])) {
                                 $this->expressions = ArrayHelper::merge($this->expressions, $uses['expression']);
                                 unset($this->columnUsed['expression']);
                             }
                         }
                         $this->used = ArrayHelper::merge($this->used, $uses);
                     } else {
                         if ($_next['class'] === 'omgdef\\multilingual\\MultilingualBehavior') {
                             $this->isMultilingual = true;
                             $this->languageField = $_next['languageField'];
                             $this->translateAttribute = $_next['attributes'];
                             $this->relationField = $_next['langForeignKey'];
                             $class = $_next['langClassName'] . ($_next['dynamicLangClass'] ? isset($_next['langClassSuffix ']) ? $_next['langClassSuffix '] : '' : '');
                             $this->relationClass = $class;
                             if (class_exists($class)) {
                                 /** @var ActiveRecord $class */
                                 $class = new $class();
                                 $this->translateTable = $class::tableName();
                             } else {
                                 $this->translateTable = $_next['tableName'];
                             }
                             $this->excludeField($class, 'translations.');
                         }
                     }
                 }
             }
         }
     }
     $this->columnUsed = ArrayHelper::merge($this->columnUsed, $this->widgetsUseClass);
 }