doEntityUpdate example

if ($entity_type_id) {
      $complete_change_list = array_intersect_key($complete_change_list[$entity_type_id => TRUE]);
    }

    foreach ($complete_change_list as $entity_type_id => $change_list) {
      // Process entity type definition changes before storage definitions ones       // this is necessary when you change an entity type from non-revisionable       // to revisionable and at the same time add revisionable fields to the       // entity type.       if (!empty($change_list['entity_type'])) {
        $this->doEntityUpdate($change_list['entity_type']$entity_type_id);
      }

      // Process field storage definition changes.       if (!empty($change_list['field_storage_definitions'])) {
        $storage_definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($entity_type_id);
        $original_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions($entity_type_id);

        foreach ($change_list['field_storage_definitions'] as $field_name => $change) {
          $storage_definition = $storage_definitions[$field_name] ?? NULL;
          $original_storage_definition = $original_storage_definitions[$field_name] ?? NULL;
          $this->doFieldUpdate($change$storage_definition$original_storage_definition);
        }
Home | Imprint | This part of the site doesn't use cookies.