Align config storage properties & mechanisms

Created on 4 July 2025, 25 days ago

Problem/Motivation

In Views integration we have:

  • builder_config_id
  • display_builder_id
  • sources

Example:

id: articles
label: Articles
module: views
display:
  page_1:
      display_extenders:
        display_builder:
          builder_config_id: default
          display_builder_id: views_6861421654810
          sources: [ ... ]

In Entity display integration, we have:

  • entity_config_id
  • sources

Example:

id: node.article.default
targetEntityType: node
bundle: article
mode: default
content: {}
hidden: {}
third_party_settings:
  display_builder:
    enabled: true
    entity_config_id: default
    sources: [ ... ]

In page layout (not a config entity yet but will be: 📌 [1.0.0-beta1] Add proper page management Active ), we have:

  • builder_config_id
  • builder_id
  • sources

Example:

id: page_layout
label: 'Page Layout'
builder_config_id: default
builder_id: page_layout_686785d880bc5
sources: []

Proposed resolution

Naming:

  • display_builder (instead of builder_config_id and entity_config_id).
  • instance (instead of builder_id and display_builder_id)
  • sources stays the same :)

But fixing the naming may not be enough. We must also align the mechanisms:

  • Entity view display has no instance because the identifier from the Drupal State API is build from the config entity identifier: display_builder_entity_view__node__article__default from node.article.default
  • Views has instance (called display_builder_id for now) because it allows to load/detach a builder instance to share theme between configs:

    but this may be overkill for most of users
  • Page Layout is not a config entity yet (see 📌 [1.0.0-beta1] Add proper page management Active ) and has also an instance (called builder_id for now) which is not visible in the UI

There are 2 ways of tidying this:

  • Adding instance to Entity view display and always showing up the instance selector
  • Or building the instance IDs of Views and Page Layout from the config entity ID, so removing both instance property and the instance selector

I have a string preference for the second option.

Proposal:

📌 Task
Status

Active

Version

1.0

Component

Main / Misc.

Created by

🇫🇷France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • 🇫🇷France pdureau Paris

    I take it because I work on similar topics in 📌 [1.0.0-beta1] Add proper page management Active

  • 🇫🇷France pdureau Paris

    Also, this is the opportunity of adding config dependency management

  • 🇫🇷France pdureau Paris

    3 information:

    • Instance ID are used in HTML classes, so let's avoid dots.
    • "display_builder_" prefix is already added by State Manager's Storage service, no need to specify it here
    • Entity ID is enough as a scope, because all entity IDs are in the same namespace

    So, proposal: {entity_type_id}--{entity_id}

  • 🇫🇷France pdureau Paris

    It seems DisplayBuilderEntityViewDisplay can also implements the upcoming EntityWithDisplayBuilderInterface :)

  • 🇫🇷France pdureau Paris

    This is also the opportunity to fix a bug in Display Buidler View: the render is made from the State Manage data instead of the data saved in config.

  • 🇫🇷France pdureau Paris

    We will also be able to remove StorageProperties::InstanceId->value, because there will have no need of storing this to config now we have EntityWithDisplayBuilderInterface::getInstanceId()

  • 🇫🇷France pdureau Paris

    Nearly done. It will be a biiiiig MR.

    DONE.

    • Implement EntityWithDisplayBuilderInterface for View
    • Implement EntityWithDisplayBuilderInterface for Entity View
    • Implement EntityWithDisplayBuilderInterface (partially) for Devel
    • Same form for all (ConfigFormBuilder)
    • Remove
      StorageProperties::InstanceId->value</code</li>
        <li>Remove <code>DisplayBuilder::DISPLAY_BUILDER_CONFIG
    • Remove enabled in Entity View
    • Fix: "the render is made from the State Manager data instead of the data saved in config
    • Remove some "dead" Layout Builder logic in Entity View
    • Remove DisplayBuilderViewsManager

    ."

    Remaining:

    • Fix regressions
    • Fix PHP Stan
    • Remove DisplayBuilderEntityViewDisplayStorage ?

    Folllow-up issue:

    • Rename EntityWithDisplayBuilderInterface to WithDisplayBuilderInterface
    • Merge StorageProperties enum to static constant in ConfigFormBuilder?
  • 🇫🇷France pdureau Paris

    Let's keep this issue and MR only for Views integration and the rest move there: 📌 Implement WithDisplayBuilderInterface in Entity View Active

  • 🇫🇷France pdureau Paris

    Everything done.

    Follow-up: 📌 WithDisplayBuilderInterface follow-ups Active

  • 🇫🇷France mogtofu33

    Fresh install with ui_patterns 2.0.5

    • Apply Patch https://www.drupal.org/project/display_builder/issues/3534215#comment-16... 📌 Align config storage properties & mechanisms Active
    • Enable the module display_builder_views
    • Disable css/js, render cache, twig cache

    Problem : All views are overridden and there is no fallback to regular view

    Quick investigation, the display_builder variable in the view templates can have an empty #cache array

    First set of tests:

    • Create a new test view for article and page
    • Set a display builder
    • Save
    • Edit the Builder and add a token and views rows, note: I don't see the DB plugin '[View] Rows' but the UI patterns source 'Views rows'

    > Visit the page, error UI Patterns (probably because of source plugin being the one from UI Patterns.

    Error: Call to a member function getOption() on null in Drupal\ui_patterns_views\Plugin\UiPatterns\Source\ViewsSourceBase->getViewsFieldOptions() (line 99 of modules/contrib/ui_patterns/modules/ui_patterns_views/src/Plugin/UiPatterns/Source/ViewsSourceBase.php).
    Drupal\ui_patterns_views\Plugin\UiPatterns\Source\ViewRowsSource->getPropValue() (Line: 206)
    Drupal\ui_patterns\SourcePluginBase->getValue() (Line: 166)
    Drupal\ui_patterns\Element\ComponentElementBuilder->buildSource() (Line: 55)
    Drupal\display_builder_views\Hook\PreprocessViewsView->preprocessViewsView() (Line: 367)
    

    Create a new view and create DB with not default config, for example devel config,
    If Enable on a view a display builder > save, then edit and change configuration for devel, same error:

    Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("view", "display") to generate a URL for route "display_builder_views.views.manage". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 189 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
    Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute() (Line: 310)
    Drupal\Core\Routing\UrlGenerator->generateFromRoute() (Line: 105)
    Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (Line: 773)
    Drupal\Core\Url->toString() (Line: 37)
    Drupal\display_builder_devel\Plugin\display_builder\Island\OperationButton->build() (Line: 393)
    Drupal\display_builder\Entity\DisplayBuilder->buildPanes() (Line: 165)
    Drupal\display_builder\Entity\DisplayBuilder->build() (Line: 68)
    Drupal\display_builder_views\Controller\ViewsController->getBuilder()

    If Display builder is enabled on a view, and the view not saved, if click on the view on the Display builder > build display, this redirect to 'Page not found'
    > Expected: If there is a link and the builder appear in 'Views builder', should be able to edit it

    Can not edit a display from 'Display builders in Views' (/admin/structure/views/display_builder), so cannot change the configuration
    If Builder deleted from 'Display builders in Views' (/admin/structure/views/display_builder), still set in the views

    When enabled display should we have the default views zone field set to not start empty?

    When add a display builder in a view, schema error:
    Schema errors for views.view.content with the following errors: views.view.content:display.page_1.display_options.display_extenders.display_builder.sources missing schema.

  • 🇫🇷France pdureau Paris

    Thanks a lot for the detailed review.

    Edit the Builder and add a token and views rows, note: I don't see the DB plugin '[View] Rows' but the UI patterns source 'Views rows'

    I will have alook.

    If Display builder is enabled on a view, and the view not saved, if click on the view on the Display builder > build display, this redirect to 'Page not found'
    > Expected: If there is a link and the builder appear in 'Views builder', should be able to edit it

    I will have a look.

    When enabled display should we have the default views zone field set to not start empty?

    It is already the case with this I believe:

      public function initInstanceIfMissing(): void {
         ...
        // Get the sources stored in config.
        $sources = $this->getSources();
        if (empty($sources)) {
          // Fallback to a fixture mimicking the standard view layout.
          $sources = DisplayBuilderHelpers::getFixtureDataFromExtension('display_builder_views');
        }
        $this->stateManager->create($instance_id, (string) $this->getDisplayBuilder()->id(), $sources, $contexts);
      }
    

    But the fixture is added to the State Maanger instance only and you need to save the Display Builder to have it in config. It works the same for 📌 [1.0.0-beta1] Add proper page management Active and 📌 Implement WithDisplayBuilderInterface in Entity View Active . Do you want to save it in config directly?

  • 🇫🇷France pdureau Paris

    Hi Jean,

    • 5 issues fixes.
    • 2 issues not reproduced
    • 1 issue abit confusing to me: Error: Call to a member function getOption(). Let's check that together?
Production build 0.71.5 2024