function file_entity_update_8003 in File Entity (fieldable files) 8.2
Update entity form displays to use the new entity browser widget.
File
- ./
file_entity.install, line 137 - Install, update and uninstall functions for the file_entity module.
Code
function file_entity_update_8003() {
/** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $form_display */
foreach (EntityFormDisplay::loadMultiple() as $form_display) {
$components = $form_display
->getComponents();
$changed = FALSE;
foreach ($components as $name => $options) {
if (isset($options['type']) && $options['type'] == 'file_entity_browser') {
$options['type'] = 'entity_browser_file';
$form_display
->setComponent($name, $options);
$changed = TRUE;
}
}
if ($changed) {
$form_display
->save();
}
}
}