You are here

function field_encrypt_has_encrypted_fields in Field Encryption 3.0.x

Verify if the given entity has encrypted fields.

Parameters

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

Return value

bool Boolean indicating whether has encrypted fields.

5 calls to field_encrypt_has_encrypted_fields()
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().
field_encrypt_entity_view in ./field_encrypt.module
Implements hook_entity_view().

File

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

Code

function field_encrypt_has_encrypted_fields(EntityInterface $entity) {

  // We can only encrypt content entities.
  if (!$entity instanceof ContentEntityInterface) {
    return FALSE;
  }

  // @todo compare performance with
  //   $entity->hasField(static::ENCRYPTED_FIELD_STORAGE_NAME).
  return in_array($entity
    ->getEntityTypeId(), \Drupal::state()
    ->get('field_encrypt.entity_types', []), TRUE);
}