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::classOnce 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
Comment #2
pdureau commentedSee also: https://www.drupal.org/project/media_library_block
Comment #3
pdureau commentedComment #4
pdureau commentedComment #5
dhansen commentedWe'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.Comment #6
pdureau commentedoh yes, we need to also select the display mode!
Comment #7
pdureau commentedComment #8
pdureau commentedComment #9
just_like_good_vibeswe wait for #3540247: Map source contexts with enums