Problem/Motivation

Today, we can only add block plugins to slots.

When using UI Patterns 2 in layout builder override or in Ckeditor5 in a content field (when it will be available), it may be useful to also be able to add content block (content entities).

Proposed resolution

Add a new source for slots

With content entities (not only content blocks).

So, we may need to pick the content entity type first, among the renderable ones:

  • Node
  • Taxonomy Term
  • User
  • Block Content
  • Comment
  • Media
  • Workspace
  • Message

So, not those ones: Path Alias, File, Menu Link.

Let's not set a manual "allowed list", we need a dynamic way, maybe by checking if view_builder attributes exist in the content entity type (this is excluding User but that may be OK):

$ grep -r "view_builder' =>" core/modules/*/src/Entity
core/modules/block_content/src/Entity/BlockContent.php:    'view_builder' => BlockContentViewBuilder::class,
core/modules/comment/src/Entity/Comment.php:    'view_builder' => CommentViewBuilder::class,
core/modules/contact/src/Entity/Message.php:    'view_builder' => MessageViewBuilder::class,
core/modules/media/src/Entity/Media.php:    'view_builder' => EntityViewBuilder::class,
core/modules/node/src/Entity/Node.php:    'view_builder' => NodeViewBuilder::class,
core/modules/taxonomy/src/Entity/Term.php:    'view_builder' => EntityViewBuilder::class,
core/modules/workspaces/src/Entity/Workspace.php:    'view_builder' => WorkspaceViewBuilder::class

Once the content entity type is picked, what do we do?

  • for media, if media_library module is available, we open a media library form element?
  • for others:
    • we select the bundle, and then we have an autocomplete reference field?
    • directly the autocomplete reference field?
    • something fancier?

Do we need to be careful with recursivity, like the Entity Reference Field is doing (break after X loops)?

Add a new context

To make this source only available when we are in a content entity, in order to avoid dependency from config to conrent.

This context must be injected in Layout Builder Override and UI Patterns Field (and the upcoming UI Patterns Ckeditor5).

Comments

pdureau created an issue. See original summary.

pdureau’s picture

pdureau’s picture

Title: [2.1.0] Add a ContentBlock source for slots with a Content entity context » [2.1.0] Add a ContentEntity source for slots with a Content entity context
Issue summary: View changes
pdureau’s picture

Issue summary: View changes
dhansen’s picture

Let's not set a manual "allowed list", we need a dynamic way, maybe by checking if view_builder attributes exist in the content entity type

We'll borrow logic from the core EntityDisplayModeController which does indeed include a check for $entity_type->hasViewBuilderClass(). It's also got a check for $entity_type->get('field_ui_base_route') which we probably won't use because we're using of the Display Modes and not trying to create them.

pdureau’s picture

t's also got a check for $entity_type->get('field_ui_base_route') which we probably won't use because we're using of the Display Modes and not trying to create them.

oh yes, we need to also select the display mode!

pdureau’s picture

pdureau’s picture

Title: [2.1.0] Add a ContentEntity source for slots with a Content entity context » Add a ContentEntity source for slots with a Content entity context
just_like_good_vibes’s picture

Status: Active » Postponed