Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay class does not correspond to an entity type.

Created on 13 April 2020, over 5 years ago
Updated 10 July 2025, 6 months ago

The Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay class does not correspond to an entity type.

Purpose:
1. To fix the custom field weight on the bottom of the page that is in the field manage page at 'admin/structure/types/manage/page/fields'

Sometimes, use add some custom fields at above page, some string fields, some table fields, and so on. Then we want to order the big fields on the bottom of page and the light weight fields like string fields on the top of page in the view page.

Then, I would like to add a alter method, as below; override some function in the base class.

reproduce steps:
1. Add a hook in module, as below:
2. drush en any other module.

/**
 * Implements hook_entity_type_alter().
 */
function custom_module_entity_type_alter(array &$entity_types) {
  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  if (\Drupal::moduleHandler()->moduleExists('layout_builder')) {
    $entity_types['entity_view_display']
      ->setClass(\Drupal\custom_module\LayoutBuilderEntityViewDisplay::class);
  }
  else {
    $entity_types['entity_view_display']
      ->setClass(\Drupal\custom_module\Entity\Entity\EntityViewDisplay;::class);
  }
}

This `LayoutBuilderEntityViewDisplay` is override init function.

And then refresh the page, the page will broken a debug message like the title.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component

layout_builder.module

Created by

πŸ‡¨πŸ‡³China John.nie

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

  • DrupalFest2021

    To celebrate Drupal’s 20th birthday, we held DrupalFest, a month-long series of virtual events focused on community, contribution, and the positive impacts Drupal has made possible. The community collaborated on Drupal contributions, built skills at training workshops, and came together with the Drupal community for events ranging from game nights to virtual happy hours.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Encountered the same problem in πŸ“Œ [1.0.0-alpha2] Play nice with layout builder Active

    Will create a MR from last patch. and use entity type manager service.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·
  • Pipeline finished with Failed
    6 months ago
    Total: 129s
    #544014
  • The Needs Review Queue Bot β†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    MR updated.

    Code quality done, Tests improved.

    Review comments addressed.

    Unrelated nightwatch failure, I retriggered the job.

  • Pipeline finished with Success
    6 months ago
    #547986
  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    I tested the layout_builder installation process. Works as expected.

  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

    Copying from a Slack conversation today:

    My concern is that this is just fixing the symptom, not the cause. This is pointing to a bug in \Drupal\Core\Entity\EntityTypeRepository::getEntityTypeFromClass()
    which is called from the static \Drupal\Core\Entity\EntityBase::loadMultiple()
    meaning this is a bug for ANYONE using that static method on an overridden class, during install time
    so why fix it only for LB?

    I pointed this out 5 years ago, at the same time as proposing the workaround. #11

    If the core committers would like to include this workaround, that's fine, but a major follow-up should be opened for the underlying bug.

  • heddn Nicaragua

    I'm not sure how this would be resolved any other way than fixing the hook_install for layout_builder to use the entityTypeManager service to get the storage. What is #11 and #39 suggesting we should do instead?

  • heddn Nicaragua

    Also, something got triggered recently because there's a lot more traffic on this issue. Anecdotally, layout_builder_st depends on layout builder has all of its functional tests falling over because it override the the view display class and this breaks all of its installs. I don't recall this happening even yesterday.

  • heddn Nicaragua

    Tagging as a contrib blocker.

  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Did a code review of this earlier, and the feedback has been addressed. I think if this is a contrib blocker it's worth committing this in it's current state, however I do think we should open an issue based on #39 to explore the underlying code around this and see if there is any generic improvements we can make.

  • Pipeline finished with Failed
    6 months ago
    #553024
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Is the long term solution will be something like in the other MR I created for POC?: https://git.drupalcode.org/project/drupal/-/merge_requests/12799/diffs?c...

  • πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

    #44 is exactly what I was looking for, thank you @grimreaper!
    This speaks directly to the bug we're experiencing here, and retains the tests from the previous MR.

  • Pipeline finished with Failed
    6 months ago
    #553041
  • Pipeline finished with Canceled
    6 months ago
    #553054
  • Pipeline finished with Failed
    6 months ago
    #553062
  • Pipeline finished with Success
    6 months ago
    #553077
  • heddn Nicaragua

    heddn β†’ changed the visibility of the branch 3127026-drupallayoutbuilderentitylayoutbuilderentityviewdisplay-class-does to hidden.

  • heddn Nicaragua

    I've been testing with the patch here from MR 12799 and did a code review as well of said MR. I think this does a better job than the previous approach. Contrib module testing can confirm the root issue is gone now. LGTM.

  • πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

    +1 for RTBC, thanks @pdureau and @heddn for being patient with my pushback, and @grimreaper for making it happen.

  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Hi,

    Thanks to have pushed the MR forward! And glad to have helped!

    +1 for RTBC too, I have retested on my contrib project, working fine too!

  • The Needs Review Queue Bot β†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • Pipeline finished with Failed
    5 months ago
    Total: 209s
    #585789
  • Pipeline finished with Success
    5 months ago
    Total: 458s
    #585800
  • πŸ‡ΊπŸ‡ΈUnited States dcam

    I fixed the PHPStan failure that caused the bot to complain. It was a minor change from @covers to @legacy-covers, so I'm restoring the RTBC status.

  • πŸ‡ΊπŸ‡ΈUnited States kmonty San Francisco, CA & Berlin, DE
  • πŸ‡«πŸ‡·France Grimreaper France πŸ‡«πŸ‡·

    Last commit is ok, back to RTBC.

  • Pipeline finished with Success
    4 months ago
    Total: 480s
    #600923
  • Pipeline finished with Failed
    3 months ago
    Total: 722s
    #637376
  • Pipeline finished with Success
    3 months ago
    Total: 620s
    #637404
  • Pipeline finished with Success
    2 months ago
    Total: 1240s
    #647849
  • Pipeline finished with Failed
    2 months ago
    Total: 1758s
    #657932
  • Pipeline finished with Success
    2 months ago
    Total: 551s
    #657986
  • Pipeline finished with Success
    about 1 month ago
    #683408
  • Status changed to Fixed about 1 month ago
Production build 0.71.5 2024