Problem/Motivation
There is not a uniform way to get layout sections for an entity
right now if you have todo something like
if ($entity->getEntityTypeId() === 'entity_view_display' && $entity instanceof LayoutBuilderEntityViewDisplay) {
return $entity->getSections();
}
elseif ($this->isEntityUsingFieldOverride($entity)) {
return $entity->get('layout_builder__layout')->getSections();
}
Proposed resolution
make it simplier.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2986403-lbtrait-3.patch | 12.17 KB | tim.plunkett |
Comments
Comment #2
phenaproximaI think this should be done using the context system, as in #2976148: Layout-based entity rendering should delegate to the correct section storage instead of hardcoding to either defaults or overrides. I will roll a patch based on that work.
The idea here is that, given N section storage plugins, you have to find one that will accept an entity and derive a list of sections from it. "Which plugin to use, given this entity" is a perfect use case for contexts. So to load sections from an entity, it would be something like this:
We could add a utility method to SectionStorageManagerInterface to streamline this (something like loadFromEntity()).
Comment #3
tim.plunkettPostponing this, but here's a patch built on the other issue.
Comment #4
damienmckennaNow that #2976148: Layout-based entity rendering should delegate to the correct section storage instead of hardcoding to either defaults or overrides has been committed, this can be worked on.
Comment #6
tim.plunkettMarking this as a duplicate