You are here

public function EncryptedFieldValueManager::getEncryptedFieldValue in Field Encryption 8.2

Get an encrypted field value.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to process.

string $field_name: The field name to retrieve.

int $delta: The field delta to retrieve.

string $property: The field property to retrieve.

Return value

string The encrypted field value.

Overrides EncryptedFieldValueManagerInterface::getEncryptedFieldValue

File

src/EncryptedFieldValueManager.php, line 81

Class

EncryptedFieldValueManager
Manager containing common functions to manage EncryptedFieldValue entities.

Namespace

Drupal\field_encrypt

Code

public function getEncryptedFieldValue(ContentEntityInterface $entity, $field_name, $delta, $property) {
  $field_value_entity = $this
    ->getExistingEntity($entity, $field_name, $delta, $property, $entity
    ->getRevisionId());
  if ($field_value_entity) {
    $langcode = $entity
      ->language()
      ->getId();
    if ($field_value_entity
      ->hasTranslation($langcode)) {
      $field_value_entity = $field_value_entity
        ->getTranslation($langcode);
    }
    return $field_value_entity
      ->getEncryptedValue();
  }
  return FALSE;
}