original_string: public function afterFind()
      {
          /** @var ActiveRecord $owner */
          $owner = $this->owner;
  
          if ($owner->isRelationPopulated('translations') && $related = $owner->getRelatedRecords()['translations']) {
              $translations = $this->indexByLanguage($related);
              foreach ($this->_languageKeys as $language) {
                  foreach ($this->attributes as $attribute) {
                      foreach ($translations as $translation) {
                          if ($translation->{$this->languageField} == $language) {
                              $attributeName = $this->localizedPrefix . $attribute;
                              $this->setMultilingualAttribute($this->getAttributeName($attribute, $language), $translation->{$attributeName});
                          }
                      }
                  }
              }
          } else if ($owner->getAttribute($this->_ownerPrimaryKey) !== null) {
              if (!$owner->isRelationPopulated('translation')) {
                  $owner->translation;
              }
  
              $translation = $owner->getRelatedRecords()['translation'];
              if ($translation) {
                  foreach ($this->attributes as $attribute) {
                      $attribute_name = $this->localizedPrefix . $attribute;
                      $owner->setMultilingualAttribute($attribute, $translation->$attribute_name);
                  }
              }
          }
  
          foreach ($this->attributes as $attribute) {
              if ($owner->hasAttribute($attribute) && $this->getMultilingualAttribute($attribute)) {
                  $owner->setAttribute($attribute, $this->getMultilingualAttribute($attribute));
              }
          }
      }
code: public function afterFind()
      {
          /** @var ActiveRecord $owner */
          $owner = $this->owner;
  
          if ($owner->isRelationPopulated('translations') && $related = $owner->getRelatedRecords()['translations']) {
              $translations = $this->indexByLanguage($related);
              foreach ($this->_languageKeys as $language) {
                  foreach ($this->attributes as $attribute) {
                      foreach ($translations as $translation) {
                          if ($translation->{$this->languageField} == $language) {
                              $attributeName = $this->localizedPrefix . $attribute;
                              $this->setMultilingualAttribute($this->getAttributeName($attribute, $language), $translation->{$attributeName});
                          }
                      }
                  }
              }
          } else if ($owner->getAttribute($this->_ownerPrimaryKey) !== null) {
              if (!$owner->isRelationPopulated('translation')) {
                  $owner->translation;
              }
  
              $translation = $owner->getRelatedRecords()['translation'];
              if ($translation) {
                  foreach ($this->attributes as $attribute) {
                      $attribute_name = $this->localizedPrefix . $attribute;
                      $owner->setMultilingualAttribute($attribute, $translation->$attribute_name);
                  }
              }
          }
  
          foreach ($this->attributes as $attribute) {
              if ($owner->hasAttribute($attribute) && $this->getMultilingualAttribute($attribute)) {
                  $owner->setAttribute($attribute, $this->getMultilingualAttribute($attribute));
              }
          }
      }
code_tokens: public function afterFind ( ) { /** @var ActiveRecord $owner */ $ owner = $ this -> owner ; if ( $ owner -> isRelationPopulated ( 'translations' ) && $ related = $ owner -> getRelatedRecords ( ) [ 'translations' ] ) { $ translations = $ this -> indexByLanguage ( $ related ) ; foreach ( $ this -> _languageKeys as $ language ) { foreach ( $ this -> attributes as $ attribute ) { foreach ( $ translations as $ translation ) { if ( $ translation -> { $ this -> languageField } == $ language ) { $ attributeName = $ this -> localizedPrefix . $ attribute ; $ this -> setMultilingualAttribute ( $ this -> getAttributeName ( $ attribute , $ language ) , $ translation -> { $ attributeName } ) ; } } } } } else if ( $ owner -> getAttribute ( $ this -> _ownerPrimaryKey ) !== null ) { if ( ! $ owner -> isRelationPopulated ( 'translation' ) ) { $ owner -> translation ; } $ translation = $ owner -> getRelatedRecords ( ) [ 'translation' ] ; if ( $ translation ) { foreach ( $ this -> attributes as $ attribute ) { $ attribute_name = $ this -> localizedPrefix . $ attribute ; $ owner -> setMultilingualAttribute ( $ attribute , $ translation -> $ attribute_name ) ; } } } foreach ( $ this -> attributes as $ attribute ) { if ( $ owner -> hasAttribute ( $ attribute ) && $ this -> getMultilingualAttribute ( $ attribute ) ) { $ owner -> setAttribute ( $ attribute , $ this -> getMultilingualAttribute ( $ attribute ) ) ; } } }
docstring: Handle 'afterFind' event of the owner.
docstring_tokens: Handle afterFind event of the owner .