public function File::preprocess in Geocoder 8.3
Same name and namespace in other branches
- 8.2 modules/geocoder_field/src/Plugin/Geocoder/Preprocessor/File.php \Drupal\geocoder_field\Plugin\Geocoder\Preprocessor\File::preprocess()
 
Processes the values of the field before geocoding.
Return value
$this
Overrides PreprocessorBase::preprocess
File
- modules/
geocoder_field/ src/ Plugin/ Geocoder/ Preprocessor/ File.php, line 67  
Class
- File
 - Provides a geocoder preprocessor plugin for file fields.
 
Namespace
Drupal\geocoder_field\Plugin\Geocoder\PreprocessorCode
public function preprocess() {
  parent::preprocess();
  foreach ($this->field
    ->getValue() as $delta => $value) {
    if ($value['target_id']) {
      $uri = FileEntity::load($value['target_id'])
        ->getFileUri();
      $value['value'] = $this->fileSystem
        ->realpath($uri);
      try {
        $this->field
          ->set($delta, $value);
      } catch (\Exception $e) {
        watchdog_exception('geocoder', $e);
      }
    }
  }
  return $this;
}