You are here

function field_post_update_entity_reference_handler_setting in Drupal 8

Fixes the 'handler' setting for entity reference fields.

1 string reference to 'field_post_update_entity_reference_handler_setting'
UpdatePathRC1TestBaseTest::testDatabaseLoaded in core/modules/system/tests/src/Functional/Update/UpdatePathRC1TestBaseTest.php
Tests that the database was properly loaded.

File

core/modules/field/field.post_update.php, line 27
Post update functions for Field module.

Code

function field_post_update_entity_reference_handler_setting() {
  foreach (FieldConfig::loadMultiple() as $field_config) {
    $field_type_manager = \Drupal::service('plugin.manager.field.field_type');
    $item_class = 'Drupal\\Core\\Field\\Plugin\\Field\\FieldType\\EntityReferenceItem';
    $class = $field_type_manager
      ->getPluginClass($field_config
      ->getType());
    if ($class === $item_class || is_subclass_of($class, $item_class)) {

      // field_field_config_presave() will fix the 'handler' setting on save.
      $field_config
        ->save();
    }
  }
  return t('Selection handler for entity reference fields have been adjusted.');
}