Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
This is a followup issue for #1871696: Convert block instances to configuration entities to resolve architectural issues.
BlockBlock
implements theBlockInterface
settings()
,access()
,form()
,validate()
,submit()
, andbuild()
methods with general handling that should apply to all blocks, and then providesblockSettings()
,blockAccess()
, etc. methods for each that allow individual block plugins to add their own handling without having to reimplement the general handling.- From an architectural standpoint, it is correct for the interface to include only the methods that matter to callers and for these methods to have simple names. See #1535868-108: Convert all blocks into plugins, #1535868-335: Convert all blocks into plugins, and #1535868-340: Convert all blocks into plugins.
- The fact that the
block*()
methods are named consistently makes the pattern easier to understand. - However, the naming is still potentially confusing since both (e.g.)
build()
andblockBuild()
return render arrays for a block.
Proposed resolution
- Discuss whether there is a better naming pattern for
blockBuild()
,blockSettings()
, etc.
Comments
Comment #1
xjmComment #2
xjmClosing as a duplicate of #1884860: Remove 'block' prefix from BlockInterface method names.
Comment #3
xjmComment #4
xjm