You are here

protected function PropertiesBase::getStringValue in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 modules/salesforce_mapping/src/Plugin/SalesforceMappingField/PropertiesBase.php \Drupal\salesforce_mapping\Plugin\SalesforceMappingField\PropertiesBase::getStringValue()

Helper Method to check for and retrieve field data.

If it is just a regular field/property of the entity, the data is retrieved with ->value(). If this is a property referenced using the typed_data module's extension, use typed_data module's DataFetcher class to retrieve the value.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to search the Typed Data for.

string $drupal_field_value: The Typed Data property to get.

Return value

string The String representation of the Typed Data property value.

1 call to PropertiesBase::getStringValue()
PropertiesBase::value in modules/salesforce_mapping/src/Plugin/SalesforceMappingField/PropertiesBase.php
Given a Drupal entity, return the outbound value.

File

modules/salesforce_mapping/src/Plugin/SalesforceMappingField/PropertiesBase.php, line 216

Class

PropertiesBase
Base class for properties plugins.

Namespace

Drupal\salesforce_mapping\Plugin\SalesforceMappingField

Code

protected function getStringValue(EntityInterface $entity, $drupal_field_value) {
  try {
    $data = $this
      ->getDataValue($entity, $drupal_field_value);
    return empty($data) ? NULL : $data
      ->getString();
  } catch (\Exception $e) {
    return NULL;
  }
}