You are here

function field_encrypt_entity_type_alter in Field Encryption 3.0.x

Same name and namespace in other branches
  1. 8.2 field_encrypt.module \field_encrypt_entity_type_alter()

Implements hook_entity_type_alter().

See also

\Drupal\field_encrypt\EventSubscriber\ConfigSubscriber::onConfigSave()

\Drupal\field_encrypt\StateManager::update()

File

./field_encrypt.module, line 199
Contains module hooks for field_encrypt.

Code

function field_encrypt_entity_type_alter(array &$entity_types) {
  if (\Drupal::config('field_encrypt.settings')
    ->get('make_entities_uncacheable')) {

    // Exclude entities from cache if they contain an encrypted field.
    foreach (\Drupal::state()
      ->get('field_encrypt.entity_types', []) as $entity_type) {

      // Ignore entity types that do not exist. This is defensive coding.
      if (isset($entity_types[$entity_type])) {
        $entity_types[$entity_type]
          ->set('render_cache', FALSE);
        $entity_types[$entity_type]
          ->set('persistent_cache', FALSE);
      }
    }
  }
}