You are here

function field_encrypt_allow_encryption in Field Encryption 8.2

Verify if the given entity allows to be encrypted.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity to check.

Return value

bool Boolean indicating hether the entity could be encrypted.

6 calls to field_encrypt_allow_encryption()
field_encrypt_entity_delete in ./field_encrypt.module
Implements hook_entity_delete().
field_encrypt_entity_insert in ./field_encrypt.module
Implements hook_entity_insert().
field_encrypt_entity_presave in ./field_encrypt.module
Implements hook_entity_presave().
field_encrypt_entity_storage_load in ./field_encrypt.module
Implements hook_entity_storage_load().
field_encrypt_entity_update in ./field_encrypt.module
Implements hook_entity_update().

... See full list

File

./field_encrypt.module, line 223
Contains module hooks for field_encrypt.

Code

function field_encrypt_allow_encryption(EntityInterface $entity) {
  $allowed = TRUE;

  // We don't want to encrypt the encrypted data storage.
  if ($entity instanceof Drupal\field_encrypt\Entity\EncryptedFieldValueInterface) {
    $allowed = FALSE;
  }

  // We only want to encrypt content entities.
  if (!$entity instanceof Drupal\Core\Entity\ContentEntityInterface) {
    $allowed = FALSE;
  }
  return $allowed;
}