Problem/Motivation

Navigating to Manage Layout for a content type display yields the exception:

Drupal\Component\Plugin\Exception\ContextException: The entity context is not a valid context. in Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase->getContextDefinition() (line 184 of /var/www/docroot/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php).

This is because there is no entity context for a display. The code assumes you are managing the layout for an individual content node.

Steps to reproduce

Navigate to a content type view display that is Layout Builder enabled and click Manage Layout.

Example URL: /admin/structure/types/manage/{content_type_name}/display/default/layout

Proposed resolution

Check if the context is valid.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

john.oltman created an issue. See original summary.

john.oltman’s picture

Issue summary: View changes
john.oltman’s picture

StatusFileSize
new2.75 KB
john.oltman’s picture

StatusFileSize
new4.35 KB

This version catches a few different errors.

viren18febS made their first commit to this issue’s fork.

viren18febs’s picture

Status: Active » Needs review
StatusFileSize
new3.5 KB

I have added a patch with dependency injection for event dispatcher, please review.

mauhg’s picture

StatusFileSize
new4.27 KB

Reroll from patch #4, since it was not applying correctly for me.
Reroll from module's dev version

rajab natshah’s picture

Facing the same issue when editing the layout for the default layout in the content type, taxonomies, block type, mini layouts, and other entities.

rajab natshah’s picture

Title: Drupal\Component\Plugin\Exception\ContextException: The entity context is not a valid context. » Fix not a valid context for entity context when editing the default layout entity types or bundles
rajab natshah’s picture

Title: Fix not a valid context for entity context when editing the default layout entity types or bundles » Fix not valid context for entity context when editing the default layout entity types or bundles
rajab natshah’s picture

Status: Needs review » Reviewed & tested by the community

Thank you, Mauricio
The #7 patch is working

carlos romero made their first commit to this issue’s fork.

  • sdstyles committed 6099ebeb on 2.x
    Issue #3392780 by john.oltman, viren18febs, mauhg, carlos romero, rajab...
sdstyles’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all for fixing it!

  • sdstyles committed 6099ebeb on 2.1.x
    Issue #3392780 by john.oltman, viren18febs, mauhg, carlos romero, rajab...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.