Remove WithDisplayBuilderInterface::initInstanceIfMissing()

Created on 3 September 2025, 3 days ago

Problem/Motivation

All implementations of WithDisplayBuilderInterface::initInstanceIfMissing() are strictly identical:

  public function initInstanceIfMissing(): void {
    /** @var \Drupal\display_builder\InstanceStorage $storage */
    $storage = $this->entityTypeManager->getStorage('display_builder_instance');

    /** @var \Drupal\display_builder\InstanceInterface $instance */
    $instance = $storage->load($this->getInstanceId());

    if (!$instance) {
      $instance = $storage->createFromImplementation($this);
      $instance->save();
    }
  }

In:

  • modules/custom/display_builder/modules/display_builder_entity_view/src/Entity/EntityViewDisplayTrait.php
  • modules/custom/display_builder/modules/display_builder_entity_view/src/Field/DisplayBuilderItemList.php
  • modules/custom/display_builder/modules/display_builder_page_layout/src/Entity/PageLayout.php
  • modules/custom/display_builder/modules/display_builder_views/src/Plugin/views/display_extender/DisplayExtender.php

Proposed resolution

Centralize the logic in \Drupal\display_builder\InstanceStorage or somewhere else ?

📌 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

Comments & Activities

Production build 0.71.5 2024