refactor: #3639285 Use OOP hooks and fix Drupal 11.3 deprecations

Description

Moves Entity Embed's hooks to an OOP hook class, now that 8.x-1.x requires Drupal 11.3, and fixes the Drupal 11.3 deprecations phpstan and the phpunit jobs report.

Issue: https://www.drupal.org/project/entity_embed/issues/3639285

  • New Drupal\entity_embed\Hook\EntityEmbedHooks with every hook from entity_embed.module, except hook_ckeditor4to5upgrade_plugin_info_alter(), which #3639510 removes.
  • template_preprocess_entity_embed_container() is now an initial preprocess callback, EntityEmbedHooks::preprocessEntityEmbedContainer().
  • entity_embed_filter_format_edit_form_validate() is now EntityEmbedHooks::validateFilterFormatForm().
  • FieldFormatterEntityEmbedDisplayBase::build() sets #printed instead of calling the deprecated show().
  • DrupalEntityDeriver keeps the entity type manager instead of the embed button storage ($embedButtonStorage is removed).

Testing instructions

  1. Visit /admin/help/entity_embed: the help page shows "About" and "Uses".
  2. Embed a media item or node in a text field with an Entity Embed button and save: it renders as before.
  3. Edit the text format at /admin/config/content/formats, enable "Align images", and move it below "Display embedded entities" in the filter order. Saving shows "The Display embedded entities filter needs to be placed after the Align images filter."

Remaining tasks

  • Release note: entity_embed_filter_format_edit_form_validate() and template_preprocess_entity_embed_container() are removed; their code moved to EntityEmbedHooks.

AI disclosure

Claude Code (Claude Opus 5.5) moved the hooks into the new class, made the deprecation fixes and wrote this description. I chose to convert the hooks without #[LegacyHook] wrappers since 8.x-1.x requires Drupal 11.3, to leave the CKEditor 4 to 5 upgrade hook for #3639510, and I ran the kernel, functional and FunctionalJavascript tests, phpcs and phpstan locally.

🤖 Generated with Claude Code

Edited by Dave Reid

Merge request reports

Loading
Loading