Example #1
0
 /**
  * @inheritdoc
  */
 public function attach($owner)
 {
     // Extract data for auto rules and extract relations info
     $map = function ($config) use($owner) {
         if (is_array($config)) {
             if (isset($config[0])) {
                 $this->rules[] = [[$config[0]], 'safe', 'on' => 'ycm-search'];
                 $this->rules[] = [[$config[0]], 'safe', 'on' => 'default'];
             }
             if (isset($config[1]) && $config[1] == 'relation' && ($relation = $owner->getRelation($config[0], false))) {
                 $this->relations_info[$config[0]] = $relation;
                 if (!$relation->multiple) {
                     $this->relations_to_fields_map[$config[0]] = reset($relation->link);
                 }
             }
         }
     };
     if (method_exists($owner, 'attributeWidgets')) {
         array_map($map, $owner->attributeWidgets());
     }
     if (method_exists($owner, 'gridViewColumns')) {
         array_map($map, $owner->gridViewColumns());
     }
     if (method_exists($owner, 'search')) {
         $search = $owner->search([]);
         if (is_array($search)) {
             array_map($map, $search);
         }
     }
     parent::attach($owner);
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function attach($owner)
 {
     if (property_exists($owner, Module::MODEL_MULTILANG_PROPERTY_NAME)) {
         foreach ((array) $owner->attributes_multilang as $attribute_multilang) {
             foreach (ModelHelper::getMultiLangAttributes($owner, $attribute_multilang) as $attribute) {
                 $this->rules[] = [[$attribute], 'safe', 'on' => 'default'];
             }
         }
     }
     parent::attach($owner);
 }