protected function FieldEncryptProcessEntities::processEntity in Field Encryption 8.2
Process an entity to either encrypt or decrypt its fields.
Both processes are very similar, so we bundle the field processing part.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to process.
string $op: The operation to perform (encrypt / decrypt).
2 calls to FieldEncryptProcessEntities::processEntity()
- FieldEncryptProcessEntities::decryptEntity in src/
FieldEncryptProcessEntities.php - Decrypt fields for an entity.
- FieldEncryptProcessEntities::encryptEntity in src/
FieldEncryptProcessEntities.php - Encrypt fields for an entity.
File
- src/
FieldEncryptProcessEntities.php, line 114
Class
- FieldEncryptProcessEntities
- Service class to process entities and fields for encryption.
Namespace
Drupal\field_encryptCode
protected function processEntity(ContentEntityInterface $entity, $op = 'encrypt') {
// Make sure we can get fields.
if (!is_callable([
$entity,
'getFields',
])) {
return;
}
// Process all language variants of the entity.
$languages = $entity
->getTranslationLanguages();
foreach ($languages as $language) {
$translated_entity = $entity
->getTranslation($language
->getId());
foreach ($translated_entity
->getFields() as $field) {
$this
->processField($translated_entity, $field, $op);
}
}
}