You are here

protected function ProcessEntities::getEncryptedFields in Field Encryption 3.0.x

Gets the encrypted fields from the entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity with encrypted fields.

Return value

iterable An iterator over the fields which are configured to be encrypted.

2 calls to ProcessEntities::getEncryptedFields()
ProcessEntities::encryptEntity in src/ProcessEntities.php
Encrypts an entity's encrypted fields.
ProcessEntities::entitySetCacheTags in src/ProcessEntities.php
Sets an entity's encrypted field's cache tags appropriately.

File

src/ProcessEntities.php, line 210

Class

ProcessEntities
Service class to process entities and fields for encryption.

Namespace

Drupal\field_encrypt

Code

protected function getEncryptedFields(ContentEntityInterface $entity) {
  foreach ($entity
    ->getFields() as $field) {
    $storage = $field
      ->getFieldDefinition()
      ->getFieldStorageDefinition();
    $is_base_field = $storage
      ->isBaseField();

    // Check if the field is encrypted.
    if ($is_base_field && $storage
      ->getSetting('field_encrypt.encrypt') || !$is_base_field && $storage
      ->getThirdPartySetting('field_encrypt', 'encrypt', FALSE)) {
      (yield $field);
    }
  }
}