Change `getEntity` method visibility in BlockContentBlock plugin

Created on 2 November 2021, almost 4 years ago
Updated 12 August 2025, 13 days ago

Problem/Motivation

As developers when implementing hook_block_build_BLOCK_BASE_ID_alter or hook_block_view_BLOCK_BASE_ID_alter and dealing with BlockContentBlock plugin we may want to get information from the underlaying content entity loaded by the plugin by calling the getEntity but is declared as protected. As result, we may end duplicating the load logic from the block or decorating the plugin class, both utterly waste of time and efforts.

Steps to reproduce

N/A

Proposed resolution

Make getEntity method public and either declare the method in an exising Interface or introduce one (better than just implementation)

Remaining tasks

  • Provide an initial patch
  • Interface proposal
  • Write some tests
  • Update the documentation
  • Write a change record (if necessary)

User interface changes

N/A

API changes

TBD

Data model changes

N/A

Release notes snippet

TBD

Feature request
Status

Closed: won't fix

Version

11.0 🔥

Component

block_content.module

Created by

🇪🇸Spain d70rr3s

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.

  • 🇦🇺Australia acbramley

    Given the lack of activity here and that this method is only a handful of lines long I think it's best to keep it protected. More public API means more maintenance and BC ramifications.

    If you feel strongly about this, feel free to reopen it with more concrete examples of what this feature would provide.

Production build 0.71.5 2024