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.
Currently, the block_admin_configure_submit() submit handler runs queries directly rather than calling any API function. I think this is not a good practice. It seems to me it would be better to have the block-saving functionality factored out into a block_save()
API function -- analogous to node_save()
-- that could be reused elsewhere. In D7 a lot of these issues have been fixed (logic has been moved out of submit handlers into API) -- but clearly there are still instances of it.
Comments
Comment #1
xjmpwolanin brought a relevant point on IRC -- maybe blocks should act like proper entities?
Relevant issues:
#430886: Make all blocks fieldable entities
#1164718: Improving the usability between "custom block" and "content"
Comment #2
SilviaT CreditAttribution: SilviaT commentedsub
Comment #3
joachim CreditAttribution: joachim commentedBefore we write a block_save() we need to figure out an object schema for the block object.
block_load() only loads from the {block} table, but block_admin_configure_submit() needs to also write to {block_role}.
Comment #4
pfrenssenThis seems to be solved by the Configuration Management and Blocks Everywhere initiatives in D8. It will be possible to manipulate blocks with the config API:
Marking this as a duplicate of #1535868: Convert all blocks into plugins.