You are here

function ctools_entity_mask_entity_type_alter in Chaos Tool Suite (ctools) 8.3

Implements hook_entity_type_alter().

File

modules/ctools_entity_mask/ctools_entity_mask.module, line 51
Helps entity type to take the fields, display configuration from entity type.

Code

function ctools_entity_mask_entity_type_alter(array &$entity_types) {

  /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
  foreach ($entity_types as $entity_type) {

    // Mask entities should use our specialized storage handler, which simulates
    // a save but does not write anything to the database.
    if ($entity_type
      ->get('mask') && $entity_type
      ->getStorageClass() == SqlContentEntityStorage::class) {
      $entity_type
        ->setStorageClass(MaskContentEntityStorage::class);

      // Mask entities should not maintain any tables.
      $entity_type
        ->set('base_table', NULL);
      $entity_type
        ->set('revision_table', NULL);
      $entity_type
        ->set('data_table', NULL);
      $entity_type
        ->set('revision_data_table', NULL);

      // Nor should they be exposed to Field UI.
      $entity_type
        ->set('field_ui_base_route', NULL);
    }
  }
}