Пример #1
0
 protected function chain(Sanitize $sanitize, $input, $attribute)
 {
     $callback = function ($value) use($sanitize, $attribute) {
         if (is_array($value)) {
             if (!$this->recursive) {
                 return $value;
             }
             $this->attributes = is_array($this->attributes) && isset($this->attributes[$attribute]) ? $this->attributes[$attribute] : $this->attributes;
             return $this->sanitize($value);
         }
         return $sanitize->sanitize($value);
     };
     return ArrayHelper::updateValue($input, explode('.', $attribute), $callback);
 }
Пример #2
0
 protected function processing($row, array $fields, $value)
 {
     if (is_array($row)) {
         $callback = function () use($value) {
             return $value;
         };
         return ArrayHelper::updateValue($row, $fields, $callback, false);
     }
     $r = $row;
     foreach ($fields as $field) {
         if (!isset($r->{$field})) {
             break;
         }
         if (is_string($r->{$field})) {
             $r->{$field} = $value;
             break;
         }
         $r = $r->{$field};
     }
     return $row;
 }