You are here

public function DataProviderBase::fieldItemTokens in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 src/DataProviderBase.php \Drupal\geolocation\DataProviderBase::fieldItemTokens()

Token replacement support function, callback to token replacement function.

Parameters

array $replacements: An associative array variable containing mappings from token names to values (for use with strtr()).

array $data: Current item replacements.

array $options: A keyed array of settings and flags to control the token replacement process. See \Drupal\Core\Utility\Token::replace().

File

src/DataProviderBase.php, line 190

Class

DataProviderBase
Class DataProviderBase.

Namespace

Drupal\geolocation

Code

public function fieldItemTokens(array &$replacements, array $data, array $options) {
  if (isset($data['geolocation_current_item'])) {

    /** @var \Drupal\Core\Field\FieldItemInterface $item */
    $item = $data['geolocation_current_item'];
    foreach ($this->fieldDefinition
      ->getFieldStorageDefinition()
      ->getColumns() as $id => $column) {
      if ($item
        ->get($id) && isset($replacements['[geolocation_current_item:' . $id . ']'])) {
        $replacements['[geolocation_current_item:' . $id . ']'] = $item
          ->get($id)
          ->getValue();
      }
    }
  }
}