function hook_field_encrypt_allow_encryption in Field Encryption 8.2
Same name and namespace in other branches
- 3.0.x field_encrypt.api.php \hook_field_encrypt_allow_encryption()
Hook to specify if a field property on a given entity should be encrypted.
Allows other modules to specify whether a specific field property should not be encrypted by field_encrypt module, regardless of the field encryption settings set in the field storage configuration.
If conditions are met where a field property should not be encrypted, return FALSE in your hook implementation.
Note: this only stops the encryption of a field that was set up to be encrypted. It does not allow a field without field encryption settings to be encrypted, because there are no settings defined to do so.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to encrypt fields on.
string $field_name: The field name to update.
string $delta: The field delta.
string $property_name: The field property name.
Return value
bool Return FALSE if field property should not be encrypted.
1 invocation of hook_field_encrypt_allow_encryption()
- FieldEncryptProcessEntities::allowEncryption in src/
FieldEncryptProcessEntities.php - Defines if a given field + property on an entity should be encrypted.
File
- ./
field_encrypt.api.php, line 70 - Hooks for Field Encrypt module.
Code
function hook_field_encrypt_allow_encryption(\Drupal\Core\Entity\ContentEntityInterface $entity, $field_name, $delta, $property_name) {
// Only encrypt fields on unpublished nodes.
if ($entity instanceof \Drupal\node\Entity\Node) {
if ($entity
->isPublished()) {
return FALSE;
}
}
}