You are here

public function Token::value in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Token.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Token::value()
  2. 5.0.x modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Token.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\Token::value()

Given a Drupal entity, return the outbound value.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity being mapped.

\Drupal\salesforce_mapping\Entity\SalesforceMappingInterface $mapping: The parent SalesforceMapping to which this plugin config belongs.

Overrides SalesforceMappingFieldPluginInterface::value

File

modules/salesforce_mapping/src/Plugin/SalesforceMappingField/Token.php, line 108

Class

Token
Adapter for entity Token and fields.

Namespace

Drupal\salesforce_mapping\Plugin\SalesforceMappingField

Code

public function value(EntityInterface $entity, SalesforceMappingInterface $mapping) {
  $text = $this
    ->config('drupal_field_value');
  $data = [
    $entity
      ->getEntityTypeId() => $entity,
  ];
  $options = [
    'clear' => TRUE,
  ];
  $result = $this->token
    ->replace($text, $data, $options);

  // If we have something, return it.  Otherwise return NULL.
  return trim($result) != '' ? $result : NULL;
}