function field_post_update_remove_handler_submit_setting
Remove the stale 'handler_submit' setting for entity_reference fields.
File
-
core/
modules/ field/ field.post_update.php, line 66
Code
function field_post_update_remove_handler_submit_setting() {
$config = \Drupal::configFactory();
/** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
// Iterate on all field configs.
foreach ($config->listAll('field.field.') as $field_id) {
$field = $config->getEditable($field_id);
$class = $field_type_manager->getPluginClass($field->get('field_type'));
// Deal only with entity reference fields and descendants.
if ($class === EntityReferenceItem::class || is_subclass_of($class, EntityReferenceItem::class)) {
if ($field->get('settings.handler_submit')) {
// Remove 'handler_settings' from settings.
$field->clear('settings.handler_submit')
->save();
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.