X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Ffield.module;h=4d4d4822fa612c29e52611799dccc8630de0ef6b;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=8f3877d0f3898cb1870bc68b6d4e9e01339619b5;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/field/field.module b/web/core/modules/field/field.module index 8f3877d0f..4d4d4822f 100644 --- a/web/core/modules/field/field.module +++ b/web/core/modules/field/field.module @@ -74,7 +74,7 @@ function field_help($route_name, RouteMatchInterface $route_match) { $output .= '

' . t('Terminology') . '

'; $output .= '
'; $output .= '
' . t('Entities and entity types') . '
'; - $output .= '
' . t('The website\'s content and configuration is managed using entities, which are grouped into entity types. Content entity types are the entity types for site content (such as the main site content, comments, custom blocks, taxonomy terms, and user accounts). Configuration entity types 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.') . '
'; + $output .= '
' . t("The website's content and configuration is managed using entities, which are grouped into entity types. Content entity types are the entity types for site content (such as the main site content, comments, custom blocks, taxonomy terms, and user accounts). Configuration entity types 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.") . '
'; $output .= '
' . t('Entity sub-types') . '
'; $output .= '
' . 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 bundle for entity sub-types.') . '
'; $output .= '
' . t('Fields and field types') . '
'; @@ -250,19 +250,6 @@ function field_entity_bundle_delete($entity_type_id, $bundle) { 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() - ]); - } } } } @@ -337,12 +324,12 @@ function field_form_config_admin_import_form_alter(&$form, FormStateInterface $f foreach ($field_storages as $field) { $field_labels[] = $field->label(); } - drupal_set_message(\Drupal::translation()->formatPlural( + \Drupal::messenger()->addWarning(\Drupal::translation()->formatPlural( count($field_storages), 'This synchronization will delete data from the field %fields.', 'This synchronization will delete data from the fields: %fields.', ['%fields' => implode(', ', $field_labels)] - ), 'warning'); + )); } } } @@ -407,4 +394,17 @@ function field_field_config_presave(FieldConfigInterface $field) { $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(), + ]); + } }