Problem/Motivation
preprocessBreadcrumb hook fails when loading a MenuLinkContent entity.
Other entities such as block_content might fail as well.
$entity_type = $entity->getEntityType();
$type_label = $entity_type->getSingularLabel();
$bundle_key = $entity_type->getKey('bundle');
if ($bundle_key) {
$bundle_entity = $entity->get($bundle_key)->entity;
$type_label = $bundle_entity->label();
}
The problem is that these entities declare a bundle entity key but no bundle_entity_type. Such entity types get a plain string bundle field rather than an entity_reference, so $entity->get($bundle_key)->entity is always NULL.
Steps to reproduce
- Visit a page which has a menu_link_content entity on the breadcrumb route.
- Miserably fail.
Proposed resolution
Add a check for the existence of an actual entity.
Remaining tasks
Code it
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
Issue fork drupal-3621961
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
Comment #2
idiaz.ronceroClosing, i see this has been corrected on main and had its issue