EntityViewController prevents the usage of hook_ENTITY_TYPE_build_defaults_alter

Created on 21 October 2016, over 8 years ago
Updated 24 February 2025, 3 months ago

Problem/Motivation

The EntityViewController:view() function set's the $page['#' . $page['#entity_type']] key. IMHO there is no need for that, because it's set by EntityViewBuilder::getBuildDefaults().

The problem is, when i want to replace entity x by entity z in hook_ENTITY_TYPE_build_defaults_alter, all my changes from the hook will be overwritten later in the view() function.

My use-case here is in the media_expire module, where i'am able to define a fallback image for a media entity. Is one media entity unpublished, i want to show the fallback entity instead.

Proposed resolution

Just remove that one line from EntityViewController:view(). It's already defined in EntityViewBuilder::getBuildDefaults().

πŸ› Bug report
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

entity system

Created by

πŸ‡©πŸ‡ͺGermany chr.fritsch πŸ‡©πŸ‡ͺπŸ‡ͺπŸ‡ΊπŸŒ

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

Comments & Activities

Not all content is available!

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

Production build 0.71.5 2024