original_string: public function beforeSave()
      {
          if ($this->file instanceof UploadedFile) {
  
              if (true !== $this->owner->isNewRecord) {
                  /** @var ActiveRecord $oldModel */
                  $oldModel = $this->owner->findOne($this->owner->primaryKey);
                  $behavior = static::getInstance($oldModel, $this->attribute);
                  $behavior->cleanFiles();
              }
  
              $this->owner->{$this->attribute} = implode('.',
                  array_filter([$this->file->baseName, $this->file->extension])
              );
          } else {
              if (true !== $this->owner->isNewRecord && empty($this->owner->{$this->attribute})) {
                  $this->owner->{$this->attribute} = ArrayHelper::getValue($this->owner->oldAttributes, $this->attribute,
                      null);
              }
          }
      }
code: public function beforeSave()
      {
          if ($this->file instanceof UploadedFile) {
  
              if (true !== $this->owner->isNewRecord) {
                  /** @var ActiveRecord $oldModel */
                  $oldModel = $this->owner->findOne($this->owner->primaryKey);
                  $behavior = static::getInstance($oldModel, $this->attribute);
                  $behavior->cleanFiles();
              }
  
              $this->owner->{$this->attribute} = implode('.',
                  array_filter([$this->file->baseName, $this->file->extension])
              );
          } else {
              if (true !== $this->owner->isNewRecord && empty($this->owner->{$this->attribute})) {
                  $this->owner->{$this->attribute} = ArrayHelper::getValue($this->owner->oldAttributes, $this->attribute,
                      null);
              }
          }
      }
code_tokens: public function beforeSave ( ) { if ( $ this -> file instanceof UploadedFile ) { if ( true !== $ this -> owner -> isNewRecord ) { /** @var ActiveRecord $oldModel */ $ oldModel = $ this -> owner -> findOne ( $ this -> owner -> primaryKey ) ; $ behavior = static :: getInstance ( $ oldModel , $ this -> attribute ) ; $ behavior -> cleanFiles ( ) ; } $ this -> owner -> { $ this -> attribute } = implode ( '.' , array_filter ( [ $ this -> file -> baseName , $ this -> file -> extension ] ) ) ; } else { if ( true !== $ this -> owner -> isNewRecord && empty ( $ this -> owner -> { $ this -> attribute } ) ) { $ this -> owner -> { $ this -> attribute } = ArrayHelper :: getValue ( $ this -> owner -> oldAttributes , $ this -> attribute , null ) ; } } }
docstring: Before save event.
  
  @throws \yii\base\InvalidConfigException
docstring_tokens: Before save event .