public function ProcessEntities::decryptEntity in Field Encryption 3.0.x
Decrypts an entity's encrypted fields.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to decrypt.
See also
field_encrypt_entity_storage_load()
File
- src/
ProcessEntities.php, line 113
Class
- ProcessEntities
- Service class to process entities and fields for encryption.
Namespace
Drupal\field_encryptCode
public function decryptEntity(ContentEntityInterface $entity) {
// Make sure there is a base field to store encrypted data.
if (!$entity
->hasField(static::ENCRYPTED_FIELD_STORAGE_NAME)) {
return;
}
// Process all language variants of the entity.
$languages = $entity
->getTranslationLanguages();
foreach ($languages as $language) {
$translated_entity = $entity
->getTranslation($language
->getId());
$this
->setEncryptedFieldValues($translated_entity);
}
}