$output .= '<h3>' . t('Terminology') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Entities and entity types') . '</dt>';
- $output .= '<dd>' . t('The website\'s content and configuration is managed using <em>entities</em>, which are grouped into <em>entity types</em>. <em>Content entity types</em> are the entity types for site content (such as the main site content, comments, custom blocks, taxonomy terms, and user accounts). <em>Configuration entity types</em> are used to store configuration information for your site, such as individual views in the Views module, and settings for your main site content types.') . '</dd>';
+ $output .= '<dd>' . t("The website's content and configuration is managed using <em>entities</em>, which are grouped into <em>entity types</em>. <em>Content entity types</em> are the entity types for site content (such as the main site content, comments, custom blocks, taxonomy terms, and user accounts). <em>Configuration entity types</em> are used to store configuration information for your site, such as individual views in the Views module, and settings for your main site content types.") . '</dd>';
$output .= '<dt>' . t('Entity sub-types') . '</dt>';
$output .= '<dd>' . t('Some content entity types are further grouped into sub-types (for example, you could have article and page content types within the main site content entity type, and tag and category vocabularies within the taxonomy term entity type); other entity types, such as user accounts, do not have sub-types. Programmers use the term <em>bundle</em> for entity sub-types.') . '</dd>';
$output .= '<dt>' . t('Fields and field types') . '</dt>';
unset($handler_settings['target_bundles'][$bundle]);
$field_config->setSetting('handler_settings', $handler_settings);
$field_config->save();
-
- // In case we deleted the only target bundle allowed by the field we
- // have to log a critical message because the field will not function
- // correctly anymore.
- if ($handler_settings['target_bundles'] === []) {
- \Drupal::logger('entity_reference')->critical('The %target_bundle bundle (entity type: %target_entity_type) was deleted. As a result, the %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', [
- '%target_bundle' => $bundle,
- '%target_entity_type' => $entity_type_id,
- '%field_name' => $field_config->getName(),
- '%entity_type' => $field_config->getTargetEntityTypeId(),
- '%bundle' => $field_config->getTargetBundle()
- ]);
- }
}
}
}
$selection_manager = \Drupal::service('plugin.manager.entity_reference_selection');
list($current_handler) = explode(':', $field->getSetting('handler'), 2);
$field->setSetting('handler', $selection_manager->getPluginId($target_type, $current_handler));
+
+ // In case we removed all the target bundles allowed by the field in
+ // EntityReferenceItem::onDependencyRemoval() or field_entity_bundle_delete()
+ // we have to log a critical message because the field will not function
+ // correctly anymore.
+ $handler_settings = $field->getSetting('handler_settings');
+ if (isset($handler_settings['target_bundles']) && $handler_settings['target_bundles'] === []) {
+ \Drupal::logger('entity_reference')->critical('The %field_name entity reference field (entity_type: %entity_type, bundle: %bundle) no longer has any valid bundle it can reference. The field is not working correctly anymore and has to be adjusted.', [
+ '%field_name' => $field->getName(),
+ '%entity_type' => $field->getTargetEntityTypeId(),
+ '%bundle' => $field->getTargetBundle(),
+ ]);
+ }
}