You are here

function hook_field_encrypt_allow_encryption in Field Encryption 3.0.x

Same name and namespace in other branches
  1. 8.2 field_encrypt.api.php \hook_field_encrypt_allow_encryption()

Hook to specify if a given entity should be encrypted.

Allows other modules to specify whether an entity should not be encrypted by field_encrypt module, regardless of the field encryption settings.

If conditions are met where an entity should not be encrypted, return FALSE in your hook implementation.

Note: this only stops the encryption of an entity that was set up to be encrypted. It does not allow an entity that is not configured to be encrypted, because there are no settings defined to do so.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to encrypt fields on.

Return value

bool Return FALSE if entity should not be encrypted.

1 function implements hook_field_encrypt_allow_encryption()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_encrypt_test_field_encrypt_allow_encryption in tests/modules/field_encrypt_test/field_encrypt_test.module
Implements hook_field_encrypt_allow_encryption().
1 invocation of hook_field_encrypt_allow_encryption()
ProcessEntities::encryptEntity in src/ProcessEntities.php
Encrypts an entity's encrypted fields.

File

./field_encrypt.api.php, line 29
Hooks for Field Encrypt module.

Code

function hook_field_encrypt_allow_encryption(\Drupal\Core\Entity\ContentEntityInterface $entity) {

  // Only encrypt fields on unpublished nodes.
  if ($entity instanceof Node) {
    if ($entity
      ->isPublished()) {
      return FALSE;
    }
  }
}