You are here

protected function FieldEncryptProcessEntities::allowEncryption in Field Encryption 8.2

Defines if a given field + property on an entity should be encrypted.

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 Whether to encrypt this field or not.

1 call to FieldEncryptProcessEntities::allowEncryption()
FieldEncryptProcessEntities::processValue in src/FieldEncryptProcessEntities.php
Encrypt or decrypt a value.

File

src/FieldEncryptProcessEntities.php, line 308

Class

FieldEncryptProcessEntities
Service class to process entities and fields for encryption.

Namespace

Drupal\field_encrypt

Code

protected function allowEncryption(ContentEntityInterface $entity, $field_name, $delta, $property_name, FieldItemListInterface $field_list, $field_value) {
  if ($field_value === $this
    ->getUnencryptedPlaceholderValue($entity, $field_list, $property_name)) {
    return FALSE;
  }
  foreach (\Drupal::moduleHandler()
    ->getImplementations('field_encrypt_allow_encryption') as $module) {
    if (\Drupal::moduleHandler()
      ->invoke($module, 'field_encrypt_allow_encryption', [
      $entity,
      $field_name,
      $delta,
      $property_name,
    ]) === FALSE) {
      return FALSE;
    }
  }
  return TRUE;
}