Problem/Motivation

In the parent issue #3372092: Allow field_type_categories.yml entries to define asset libraries there are multiple instances where we check for fallback category. It can be eliminated by always providing the general category in the the plugin manager and making sure that it remains unaltered.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#4 3383080.patch5.75 KBamateescu

Comments

srishtiiee created an issue. See original summary.

srishtiiee’s picture

Title: Provide the general category within the plugin manager, and ensure that it remains unaltered » Provide the 'general' category within the plugin manager, and ensure that it remains unaltered
Issue summary: View changes
srishtiiee’s picture

Issue tags: +Field UX
amateescu’s picture

Status: Active » Needs review
StatusFileSize
new5.75 KB

Could be as simple as this :)

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

@amateescu LGTM!

P.S.: I do think it's still slightly confusing, but this is out of scope. What do you think, @amateescu and others?

+++ b/core/lib/Drupal/Core/Field/FieldTypeCategoryManager.php
@@ -79,6 +79,17 @@ protected function getDiscovery(): YamlDiscovery {
+    if (!isset($definitions[FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY])) {
+      throw new \LogicException('Missing fallback category.');

+++ b/core/modules/comment/comment.module
@@ -789,9 +789,7 @@ function comment_entity_view_display_presave(EntityViewDisplayInterface $display
+  // The `comment` field type belongs in the `general` category, so the
...
+  $definitions[FieldTypeCategoryManagerInterface::FALLBACK_CATEGORY]['libraries'][] = 'comment/drupal.comment-icon';

This is the thing that makes it confusing IMHO: the constant says "fallback", but it's really the "general" category.

Renaming the constant would make this clearer.

And we can still do that because this didn't ship in any release!🤞🤓

  • lauriii committed 1ea295c8 on 11.x
    Issue #3383080 by amateescu, srishtiiee, Wim Leers: Provide the 'general...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

I think we called it a fallback category because it has some special functionality, see \Drupal\Core\Field\FallbackFieldTypeCategory. It's also not rendered like other categories. Items in this category are rendered on their own, without a category, meaning it's not a real category. If we want to consider renaming or changing it, let's do that in a follow-up issue.

Committed 1ea295c and pushed to 11.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.