You are here

function conditional_fields_update_8001 in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 conditional_fields.install \conditional_fields_update_8001()

Removes unused configuration.

File

./conditional_fields.install, line 14
Conditional fields module's updates.

Code

function conditional_fields_update_8001() {
  $cf_service = \Drupal::service('conditional_fields.controller');
  $bundle_info = \Drupal::service('entity_type.bundle.info');
  $entity_types = $cf_service
    ->getEntityTypes();
  foreach ($entity_types as $entity_type) {
    $etid = $entity_type
      ->id();
    $bundles = $bundle_info
      ->getBundleInfo($etid);
    foreach ($bundles as $bundle_name => $bundle) {

      /** @var \Drupal\Core\Entity\Entity\EntityFormDisplay  $entity */
      $entity = \Drupal::entityTypeManager()
        ->getStorage('entity_form_display')
        ->load("{$etid}.{$bundle_name}.default");

      // Replace keys.
      if ($entity instanceof EntityInterface) {
        _conditional_fields_update_conditional_fields_settings($entity);
      }
      if (is_null($entity)) {
        continue;
      }
    }
  }
}