You are here

field_encrypt.api.php in Field Encryption 3.0.x

Same filename and directory in other branches
  1. 8.2 field_encrypt.api.php

Hooks for Field Encrypt module.

File

field_encrypt.api.php
View source
<?php

/**
 * @file
 * Hooks for Field Encrypt module.
 */
use Drupal\node\Entity\Node;

/**
 * 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.
 *
 * @param \Drupal\Core\Entity\ContentEntityInterface $entity
 *   The entity to encrypt fields on.
 *
 * @return bool
 *   Return FALSE if entity should not be encrypted.
 */
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;
    }
  }
}

Functions

Namesort descending Description
hook_field_encrypt_allow_encryption Hook to specify if a given entity should be encrypted.