You are here

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

Same name and namespace in other branches
  1. 8.2 src/Controller/FieldOverviewController.php \Drupal\field_encrypt\Controller\FieldOverviewController::getEncryptedFields()

Get a list of encrypted fields' storage entities.

Return value

\Drupal\Core\Field\FieldStorageDefinitionInterface[] An array of FieldStorageConfig entities and base fields for encrypted fields.

1 call to FieldOverviewController::getEncryptedFields()
FieldOverviewController::overview in src/Controller/FieldOverviewController.php
Renders overview page of encrypted fields.

File

src/Controller/FieldOverviewController.php, line 119

Class

FieldOverviewController
Renders encrypted fields overview.

Namespace

Drupal\field_encrypt\Controller

Code

protected function getEncryptedFields() {
  $encrypted_fields = [];
  $storage = $this->entityTypeManager
    ->getStorage('field_storage_config');
  $fields = $storage
    ->loadMultiple();
  foreach ($fields as $field) {
    if ($field
      ->getThirdPartySetting('field_encrypt', 'encrypt', FALSE) == TRUE) {
      $encrypted_fields[] = $field;
    }
  }
  foreach ($this->entityTypeManager
    ->getDefinitions() as $entity_type) {

    // Only content entity types support encryption.
    if ($entity_type instanceof ContentEntityTypeInterface) {

      /** @var \Drupal\Core\Field\BaseFieldDefinition $base_field */
      foreach ($this->entityFieldManager
        ->getBaseFieldDefinitions($entity_type
        ->id()) as $base_field) {
        if ($base_field
          ->getSetting('field_encrypt.encrypt')) {
          $encrypted_fields[] = $base_field;
        }
      }
    }
  }
  return $encrypted_fields;
}