function field_update_8002 in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/field.install \field_update_8002()
The 'entity_reference' field type is now provided by core.
File
- core/
modules/ field/ field.install, line 34 - Install, update and uninstall functions for the field module.
Code
function field_update_8002() {
$config_factory = \Drupal::configFactory();
// Iterate on all configuration entities.
foreach ($config_factory
->listAll() as $id) {
$changed = FALSE;
$config = $config_factory
->getEditable($id);
// Update field storage configurations.
if (strpos($id, 'field.storage.') === 0) {
// Deal only with entity reference fields.
if ($config
->get('type') == 'entity_reference') {
// Fix the type provider.
$config
->set('module', 'core');
$changed = TRUE;
}
}
// Remove entity_reference module dependency from any configuration entity.
if ($dependencies = $config
->get('dependencies.module')) {
if (($delta = array_search('entity_reference', $dependencies)) !== FALSE) {
unset($dependencies[$delta]);
if ($dependencies) {
$config
->set('dependencies.module', array_values($dependencies));
}
else {
$config
->clear('dependencies.module');
}
$changed = TRUE;
}
}
if ($changed) {
$config
->save(TRUE);
}
}
}