summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules
diff options
context:
space:
mode:
authorLee Rowlands <lee.rowlands@previousnext.com.au>2025-05-01 07:59:47 +1000
committerLee Rowlands <lee.rowlands@previousnext.com.au>2025-05-01 07:59:47 +1000
commit308ad15102479e2a2020d12a46bcf898959f68e1 (patch)
treefac977265393e638bd99ceb10ee6cce625791261 /core/modules
parent6810f24aef13523c17d35d753cadb42ac5b9a0fc (diff)
downloaddrupal-308ad15102479e2a2020d12a46bcf898959f68e1.tar.gz
drupal-308ad15102479e2a2020d12a46bcf898959f68e1.zip
Issue #3495943 by nicxvan, berdir, ghost of drupal past, catch, larowlan: Handle module preprocess functions as OOP hooksHEAD11.x
Diffstat (limited to 'core/modules')
-rw-r--r--core/modules/announcements_feed/announcements_feed.services.yml2
-rw-r--r--core/modules/automated_cron/automated_cron.services.yml2
-rw-r--r--core/modules/ban/ban.services.yml2
-rw-r--r--core/modules/basic_auth/basic_auth.services.yml2
-rw-r--r--core/modules/block_content/block_content.services.yml2
-rw-r--r--core/modules/breakpoint/breakpoint.services.yml2
-rw-r--r--core/modules/comment/comment.module9
-rw-r--r--core/modules/comment/comment.services.yml2
-rw-r--r--core/modules/comment/src/Hook/CommentThemeHooks.php22
-rw-r--r--core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module15
-rw-r--r--core/modules/comment/tests/modules/comment_empty_title_test/src/Hook/CommentEmptyTitleTestThemeHooks.php22
-rw-r--r--core/modules/config/config.services.yml2
-rw-r--r--core/modules/config_translation/config_translation.services.yml2
-rw-r--r--core/modules/contact/contact.services.yml2
-rw-r--r--core/modules/content_moderation/content_moderation.services.yml2
-rw-r--r--core/modules/contextual/contextual.module40
-rw-r--r--core/modules/contextual/contextual.services.yml2
-rw-r--r--core/modules/contextual/src/Hook/ContextualThemeHooks.php57
-rw-r--r--core/modules/datetime/datetime.services.yml2
-rw-r--r--core/modules/datetime_range/datetime_range.services.yml2
-rw-r--r--core/modules/dblog/dblog.services.yml2
-rw-r--r--core/modules/dynamic_page_cache/dynamic_page_cache.services.yml2
-rw-r--r--core/modules/editor/editor.services.yml2
-rw-r--r--core/modules/field/field.services.yml2
-rw-r--r--core/modules/field_layout/field_layout.services.yml2
-rw-r--r--core/modules/field_ui/field_ui.services.yml2
-rw-r--r--core/modules/filter/filter.services.yml2
-rw-r--r--core/modules/help/help.services.yml2
-rw-r--r--core/modules/history/history.services.yml2
-rw-r--r--core/modules/inline_form_errors/inline_form_errors.services.yml2
-rw-r--r--core/modules/language/language.services.yml2
-rw-r--r--core/modules/link/link.services.yml2
-rw-r--r--core/modules/locale/locale.batch.inc4
-rw-r--r--core/modules/locale/locale.bulk.inc4
-rw-r--r--core/modules/locale/locale.compare.inc4
-rw-r--r--core/modules/locale/locale.fetch.inc4
-rw-r--r--core/modules/locale/locale.install4
-rw-r--r--core/modules/locale/locale.module29
-rw-r--r--core/modules/locale/locale.pages.inc4
-rw-r--r--core/modules/locale/locale.translation.inc4
-rw-r--r--core/modules/locale/src/Hook/LocaleThemeHooks.php43
-rw-r--r--core/modules/media/media.install4
-rw-r--r--core/modules/media/media.module4
-rw-r--r--core/modules/media_library/media_library.services.yml2
-rw-r--r--core/modules/menu_link_content/menu_link_content.services.yml2
-rw-r--r--core/modules/menu_ui/menu_ui.services.yml2
-rw-r--r--core/modules/migrate/migrate.services.yml2
-rw-r--r--core/modules/migrate_drupal/migrate_drupal.services.yml2
-rw-r--r--core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml2
-rw-r--r--core/modules/node/node.module24
-rw-r--r--core/modules/node/src/Hook/NodeThemeHooks.php38
-rw-r--r--core/modules/options/options.services.yml2
-rw-r--r--core/modules/path/path.services.yml2
-rw-r--r--core/modules/responsive_image/responsive_image.services.yml2
-rw-r--r--core/modules/rest/rest.services.yml2
-rw-r--r--core/modules/serialization/serialization.services.yml2
-rw-r--r--core/modules/settings_tray/settings_tray.services.yml2
-rw-r--r--core/modules/shortcut/shortcut.services.yml2
-rw-r--r--core/modules/syslog/syslog.services.yml2
-rw-r--r--core/modules/system/tests/modules/hook_collector_skip_procedural/hook_collector_skip_procedural.services.yml2
-rw-r--r--core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module4
-rw-r--r--core/modules/system/tests/modules/module_test_oop_preprocess/module_test_oop_preprocess.info.yml5
-rw-r--r--core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php24
-rw-r--r--core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.info.yml5
-rw-r--r--core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module20
-rw-r--r--core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php22
-rw-r--r--core/modules/system/tests/modules/theme_test/theme_test.module7
-rw-r--r--core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php50
-rw-r--r--core/modules/text/text.services.yml2
-rw-r--r--core/modules/toolbar/toolbar.services.yml2
-rw-r--r--core/modules/update/update.authorize.inc4
-rw-r--r--core/modules/update/update.compare.inc4
-rw-r--r--core/modules/update/update.fetch.inc4
-rw-r--r--core/modules/update/update.install4
-rw-r--r--core/modules/update/update.manager.inc4
-rw-r--r--core/modules/update/update.module4
-rw-r--r--core/modules/update/update.report.inc2
-rw-r--r--core/modules/workflows/workflows.services.yml2
78 files changed, 386 insertions, 200 deletions
diff --git a/core/modules/announcements_feed/announcements_feed.services.yml b/core/modules/announcements_feed/announcements_feed.services.yml
index b9e88231be1..ea927c887d1 100644
--- a/core/modules/announcements_feed/announcements_feed.services.yml
+++ b/core/modules/announcements_feed/announcements_feed.services.yml
@@ -1,7 +1,7 @@
parameters:
announcements_feed.feed_json_url: https://www.drupal.org/announcements.json
announcements_feed.feed_link: https://www.drupal.org/about/announcements
- announcements_feed.hooks_converted: true
+ announcements_feed.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/automated_cron/automated_cron.services.yml b/core/modules/automated_cron/automated_cron.services.yml
index bbb55f5f6f3..0cc66d22384 100644
--- a/core/modules/automated_cron/automated_cron.services.yml
+++ b/core/modules/automated_cron/automated_cron.services.yml
@@ -1,5 +1,5 @@
parameters:
- automated_cron.hooks_converted: true
+ automated_cron.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/ban/ban.services.yml b/core/modules/ban/ban.services.yml
index 7bd8a245e5f..585f8fa0d60 100644
--- a/core/modules/ban/ban.services.yml
+++ b/core/modules/ban/ban.services.yml
@@ -1,5 +1,5 @@
parameters:
- ban.hooks_converted: true
+ ban.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/basic_auth/basic_auth.services.yml b/core/modules/basic_auth/basic_auth.services.yml
index 09b21c68f33..af0de75629e 100644
--- a/core/modules/basic_auth/basic_auth.services.yml
+++ b/core/modules/basic_auth/basic_auth.services.yml
@@ -1,5 +1,5 @@
parameters:
- basic_auth.hooks_converted: true
+ basic_auth.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/block_content/block_content.services.yml b/core/modules/block_content/block_content.services.yml
index eb8b9924ce9..2661eda513b 100644
--- a/core/modules/block_content/block_content.services.yml
+++ b/core/modules/block_content/block_content.services.yml
@@ -1,5 +1,5 @@
parameters:
- block_content.hooks_converted: true
+ block_content.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/breakpoint/breakpoint.services.yml b/core/modules/breakpoint/breakpoint.services.yml
index 7558eb6d765..46d8f0d27e1 100644
--- a/core/modules/breakpoint/breakpoint.services.yml
+++ b/core/modules/breakpoint/breakpoint.services.yml
@@ -1,5 +1,5 @@
parameters:
- breakpoint.hooks_converted: true
+ breakpoint.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index b357f3069ae..139513c1c37 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -111,15 +111,6 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta
}
/**
- * Implements hook_preprocess_HOOK() for block templates.
- */
-function comment_preprocess_block(&$variables): void {
- if ($variables['configuration']['provider'] == 'comment') {
- $variables['attributes']['role'] = 'navigation';
- }
-}
-
-/**
* Prepares variables for comment templates.
*
* By default this function performs special preprocessing of some base fields
diff --git a/core/modules/comment/comment.services.yml b/core/modules/comment/comment.services.yml
index 22cc8f9a428..7f9e8224551 100644
--- a/core/modules/comment/comment.services.yml
+++ b/core/modules/comment/comment.services.yml
@@ -1,5 +1,5 @@
parameters:
- comment.hooks_converted: true
+ comment.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/comment/src/Hook/CommentThemeHooks.php b/core/modules/comment/src/Hook/CommentThemeHooks.php
new file mode 100644
index 00000000000..e789af6dab1
--- /dev/null
+++ b/core/modules/comment/src/Hook/CommentThemeHooks.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Drupal\comment\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+
+/**
+ * Hook implementations for comment.
+ */
+class CommentThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK() for block templates.
+ */
+ #[Preprocess('block')]
+ public function preprocessBlock(&$variables): void {
+ if ($variables['configuration']['provider'] == 'comment') {
+ $variables['attributes']['role'] = 'navigation';
+ }
+ }
+
+}
diff --git a/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module b/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module
deleted file mode 100644
index c107fd11466..00000000000
--- a/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-/**
- * @file
- * Empties comment titles to test markup in edge case scenarios.
- */
-
-declare(strict_types=1);
-
-/**
- * Implements hook_preprocess_comment().
- */
-function comment_empty_title_test_preprocess_comment(&$variables): void {
- $variables['title'] = '';
-}
diff --git a/core/modules/comment/tests/modules/comment_empty_title_test/src/Hook/CommentEmptyTitleTestThemeHooks.php b/core/modules/comment/tests/modules/comment_empty_title_test/src/Hook/CommentEmptyTitleTestThemeHooks.php
new file mode 100644
index 00000000000..db1ffae5a6d
--- /dev/null
+++ b/core/modules/comment/tests/modules/comment_empty_title_test/src/Hook/CommentEmptyTitleTestThemeHooks.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\comment_empty_title_test\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+
+/**
+ * Hook implementations for comment_empty_title_test.
+ */
+class CommentEmptyTitleTestThemeHooks {
+
+ /**
+ * Implements hook_preprocess_comment().
+ */
+ #[Preprocess('comment')]
+ public function preprocessComment(&$variables): void {
+ $variables['title'] = '';
+ }
+
+}
diff --git a/core/modules/config/config.services.yml b/core/modules/config/config.services.yml
index 8667240a82f..49a17dd4008 100644
--- a/core/modules/config/config.services.yml
+++ b/core/modules/config/config.services.yml
@@ -1,5 +1,5 @@
parameters:
- config.hooks_converted: true
+ config.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/config_translation/config_translation.services.yml b/core/modules/config_translation/config_translation.services.yml
index 5c35e5ee588..458905d0629 100644
--- a/core/modules/config_translation/config_translation.services.yml
+++ b/core/modules/config_translation/config_translation.services.yml
@@ -1,5 +1,5 @@
parameters:
- config_translation.hooks_converted: true
+ config_translation.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/contact/contact.services.yml b/core/modules/contact/contact.services.yml
index b078fd2cfdc..61ec8dd7fda 100644
--- a/core/modules/contact/contact.services.yml
+++ b/core/modules/contact/contact.services.yml
@@ -1,5 +1,5 @@
parameters:
- contact.hooks_converted: true
+ contact.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/content_moderation/content_moderation.services.yml b/core/modules/content_moderation/content_moderation.services.yml
index 85abe7b2f7c..8977847173c 100644
--- a/core/modules/content_moderation/content_moderation.services.yml
+++ b/core/modules/content_moderation/content_moderation.services.yml
@@ -1,5 +1,5 @@
parameters:
- content_moderation.hooks_converted: true
+ content_moderation.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/contextual/contextual.module b/core/modules/contextual/contextual.module
index f6c3335b619..8daec06c8ee 100644
--- a/core/modules/contextual/contextual.module
+++ b/core/modules/contextual/contextual.module
@@ -8,46 +8,6 @@ use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Language\LanguageInterface;
/**
- * Implements hook_preprocess().
- *
- * @see \Drupal\contextual\Element\ContextualLinksPlaceholder
- * @see contextual_page_attachments()
- * @see \Drupal\contextual\ContextualController::render()
- */
-function contextual_preprocess(&$variables, $hook, $info): void {
- // Determine the primary theme function argument.
- if (!empty($info['variables'])) {
- $keys = array_keys($info['variables']);
- $key = $keys[0];
- }
- elseif (!empty($info['render element'])) {
- $key = $info['render element'];
- }
- if (!empty($key) && isset($variables[$key])) {
- $element = $variables[$key];
- }
-
- if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
- $variables['#cache']['contexts'][] = 'user.permissions';
- if (\Drupal::currentUser()->hasPermission('access contextual links')) {
- // Mark this element as potentially having contextual links attached to
- // it.
- $variables['attributes']['class'][] = 'contextual-region';
-
- // Renders a contextual links placeholder unconditionally, thus not
- // breaking the render cache. Although the empty placeholder is rendered
- // for all users, contextual_page_attachments() only adds the asset
- // library for users with the 'access contextual links' permission, thus
- // preventing unnecessary HTTP requests for users without that permission.
- $variables['title_suffix']['contextual_links'] = [
- '#type' => 'contextual_links_placeholder',
- '#id' => _contextual_links_to_id($element['#contextual_links']),
- ];
- }
- }
-}
-
-/**
* Serializes #contextual_links property value array to a string.
*
* Examples:
diff --git a/core/modules/contextual/contextual.services.yml b/core/modules/contextual/contextual.services.yml
index dff437ec339..558e7d029ae 100644
--- a/core/modules/contextual/contextual.services.yml
+++ b/core/modules/contextual/contextual.services.yml
@@ -1,2 +1,2 @@
parameters:
- contextual.hooks_converted: true
+ contextual.skip_procedural_hook_scan: true
diff --git a/core/modules/contextual/src/Hook/ContextualThemeHooks.php b/core/modules/contextual/src/Hook/ContextualThemeHooks.php
new file mode 100644
index 00000000000..47db1f9bde6
--- /dev/null
+++ b/core/modules/contextual/src/Hook/ContextualThemeHooks.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Drupal\contextual\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Hook implementations for contextual.
+ */
+class ContextualThemeHooks {
+
+ public function __construct(
+ protected readonly AccountInterface $currentUser,
+ ) {}
+
+ /**
+ * Implements hook_preprocess().
+ *
+ * @see \Drupal\contextual\Element\ContextualLinksPlaceholder
+ * @see contextual_page_attachments()
+ * @see \Drupal\contextual\ContextualController::render()
+ */
+ #[Preprocess]
+ public function preprocess(&$variables, $hook, $info): void {
+ // Determine the primary theme function argument.
+ if (!empty($info['variables'])) {
+ $keys = array_keys($info['variables']);
+ $key = $keys[0];
+ }
+ elseif (!empty($info['render element'])) {
+ $key = $info['render element'];
+ }
+ if (!empty($key) && isset($variables[$key])) {
+ $element = $variables[$key];
+ }
+
+ if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
+ $variables['#cache']['contexts'][] = 'user.permissions';
+ if ($this->currentUser->hasPermission('access contextual links')) {
+ // Mark this element as potentially having contextual links attached to it.
+ $variables['attributes']['class'][] = 'contextual-region';
+
+ // Renders a contextual links placeholder unconditionally, thus not breaking
+ // the render cache. Although the empty placeholder is rendered for all
+ // users, contextual_page_attachments() only adds the asset library for
+ // users with the 'access contextual links' permission, thus preventing
+ // unnecessary HTTP requests for users without that permission.
+ $variables['title_suffix']['contextual_links'] = [
+ '#type' => 'contextual_links_placeholder',
+ '#id' => _contextual_links_to_id($element['#contextual_links']),
+ ];
+ }
+ }
+ }
+
+}
diff --git a/core/modules/datetime/datetime.services.yml b/core/modules/datetime/datetime.services.yml
index af7d5c9a4d1..3f9c511d1e7 100644
--- a/core/modules/datetime/datetime.services.yml
+++ b/core/modules/datetime/datetime.services.yml
@@ -1,5 +1,5 @@
parameters:
- datetime.hooks_converted: true
+ datetime.skip_procedural_hook_scan: true
services:
datetime.views_helper:
diff --git a/core/modules/datetime_range/datetime_range.services.yml b/core/modules/datetime_range/datetime_range.services.yml
index 6234cb0e687..6701b44dd71 100644
--- a/core/modules/datetime_range/datetime_range.services.yml
+++ b/core/modules/datetime_range/datetime_range.services.yml
@@ -1,2 +1,2 @@
parameters:
- datetime_range.hooks_converted: true
+ datetime_range.skip_procedural_hook_scan: true
diff --git a/core/modules/dblog/dblog.services.yml b/core/modules/dblog/dblog.services.yml
index 50398593fe9..477f913e6bf 100644
--- a/core/modules/dblog/dblog.services.yml
+++ b/core/modules/dblog/dblog.services.yml
@@ -1,5 +1,5 @@
parameters:
- dblog.hooks_converted: true
+ dblog.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml b/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml
index 0ec8b7c2f8d..8cee8fd0d8b 100644
--- a/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml
+++ b/core/modules/dynamic_page_cache/dynamic_page_cache.services.yml
@@ -1,5 +1,5 @@
parameters:
- dynamic_page_cache.hooks_converted: true
+ dynamic_page_cache.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/editor/editor.services.yml b/core/modules/editor/editor.services.yml
index 0db1dc61968..46f674b27ab 100644
--- a/core/modules/editor/editor.services.yml
+++ b/core/modules/editor/editor.services.yml
@@ -1,5 +1,5 @@
parameters:
- editor.hooks_converted: true
+ editor.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/field/field.services.yml b/core/modules/field/field.services.yml
index 8b0f5a33093..3e986982cdb 100644
--- a/core/modules/field/field.services.yml
+++ b/core/modules/field/field.services.yml
@@ -1,5 +1,5 @@
parameters:
- field.hooks_converted: true
+ field.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/field_layout/field_layout.services.yml b/core/modules/field_layout/field_layout.services.yml
index e099e35a953..48e3a6abe6f 100644
--- a/core/modules/field_layout/field_layout.services.yml
+++ b/core/modules/field_layout/field_layout.services.yml
@@ -1,2 +1,2 @@
parameters:
- field_layout.hooks_converted: true
+ field_layout.skip_procedural_hook_scan: true
diff --git a/core/modules/field_ui/field_ui.services.yml b/core/modules/field_ui/field_ui.services.yml
index dd094ee72aa..194b7287cef 100644
--- a/core/modules/field_ui/field_ui.services.yml
+++ b/core/modules/field_ui/field_ui.services.yml
@@ -1,5 +1,5 @@
parameters:
- field_ui.hooks_converted: true
+ field_ui.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/filter/filter.services.yml b/core/modules/filter/filter.services.yml
index 6b9c243c7ab..58caf58f76c 100644
--- a/core/modules/filter/filter.services.yml
+++ b/core/modules/filter/filter.services.yml
@@ -1,5 +1,5 @@
parameters:
- filter.hooks_converted: true
+ filter.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/help/help.services.yml b/core/modules/help/help.services.yml
index 21a8e2f3adf..2cb3ecbd8ec 100644
--- a/core/modules/help/help.services.yml
+++ b/core/modules/help/help.services.yml
@@ -1,5 +1,5 @@
parameters:
- help.hooks_converted: true
+ help.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/history/history.services.yml b/core/modules/history/history.services.yml
index 7b2b654310f..fc83944feba 100644
--- a/core/modules/history/history.services.yml
+++ b/core/modules/history/history.services.yml
@@ -1,2 +1,2 @@
parameters:
- history.hooks_converted: true
+ history.skip_procedural_hook_scan: true
diff --git a/core/modules/inline_form_errors/inline_form_errors.services.yml b/core/modules/inline_form_errors/inline_form_errors.services.yml
index 0358ee16027..f3ae13843ac 100644
--- a/core/modules/inline_form_errors/inline_form_errors.services.yml
+++ b/core/modules/inline_form_errors/inline_form_errors.services.yml
@@ -1,2 +1,2 @@
parameters:
- inline_form_errors.hooks_converted: true
+ inline_form_errors.skip_procedural_hook_scan: false
diff --git a/core/modules/language/language.services.yml b/core/modules/language/language.services.yml
index 2fc8f9ada77..93f994c4f67 100644
--- a/core/modules/language/language.services.yml
+++ b/core/modules/language/language.services.yml
@@ -1,5 +1,5 @@
parameters:
- language.hooks_converted: true
+ language.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/link/link.services.yml b/core/modules/link/link.services.yml
index becc0b945dd..de8f823e8cb 100644
--- a/core/modules/link/link.services.yml
+++ b/core/modules/link/link.services.yml
@@ -1,2 +1,2 @@
parameters:
- link.hooks_converted: true
+ link.skip_procedural_hook_scan: false
diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc
index 78033387641..0f204b6af2d 100644
--- a/core/modules/locale/locale.batch.inc
+++ b/core/modules/locale/locale.batch.inc
@@ -7,7 +7,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\Exception\InvalidStreamWrapperException;
use Drupal\Core\File\FileExists;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Url;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
@@ -37,7 +37,7 @@ require_once __DIR__ . '/locale.translation.inc';
* @param array|\ArrayAccess $context
* The batch context.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translation_batch_version_check(string $project, string $langcode, array|\ArrayAccess &$context): void {
$locale_project = \Drupal::service('locale.project')->get($project);
diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc
index e8396622d61..0cb5e905856 100644
--- a/core/modules/locale/locale.bulk.inc
+++ b/core/modules/locale/locale.bulk.inc
@@ -6,7 +6,7 @@
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\File\Exception\FileException;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Url;
use Drupal\file\FileInterface;
@@ -37,7 +37,7 @@ use Drupal\locale\Gettext;
* l10n_update functionality to feed in translation files alike.
* https://www.drupal.org/node/1191488
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translate_batch_import_files(array $options, $force = FALSE) {
$options += [
'overwrite_options' => [],
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index a1ddbf61a4f..069f200942f 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -5,7 +5,7 @@
*/
use Drupal\Core\Batch\BatchBuilder;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Utility\ProjectInfo;
/**
@@ -18,7 +18,7 @@ require_once __DIR__ . '/locale.translation.inc';
/**
* Clear the project data table.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translation_flush_projects(): void {
\Drupal::service('locale.project')->deleteAll();
}
diff --git a/core/modules/locale/locale.fetch.inc b/core/modules/locale/locale.fetch.inc
index 34d0fda2e94..678e1e25e58 100644
--- a/core/modules/locale/locale.fetch.inc
+++ b/core/modules/locale/locale.fetch.inc
@@ -5,7 +5,7 @@
*/
use Drupal\Core\Batch\BatchBuilder;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
/**
* Load the common translation API.
@@ -28,7 +28,7 @@ require_once __DIR__ . '/locale.translation.inc';
* @return array
* Batch definition array.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translation_batch_update_build($projects = [], $langcodes = [], $options = []) {
\Drupal::moduleHandler()->loadInclude('locale', 'inc', 'locale.compare');
$projects = $projects ?: array_keys(locale_translation_get_projects());
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index 30aa89000b8..f583df4426e 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -7,7 +7,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Link;
use Drupal\Core\Url;
@@ -78,7 +78,7 @@ function locale_requirements($phase): array {
/**
* Implements hook_install().
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_install(): void {
// Create the interface translations directory and ensure it's writable.
if (!$directory = \Drupal::config('locale.settings')->get('translation.path')) {
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index ba7cbc15122..3a6856d4c07 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -11,11 +11,10 @@ use Drupal\Component\Utility\UrlHelper;
use Drupal\Component\Utility\Xss;
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileSystemInterface;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Site\Settings;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Language\LanguageInterface;
use Drupal\Component\Utility\Crypt;
use Drupal\locale\LocaleEvent;
use Drupal\locale\LocaleEvents;
@@ -146,7 +145,7 @@ const LOCALE_TRANSLATION_CURRENT = 'current';
* Array of installed languages keyed by language name. English is omitted
* unless it is marked as translatable.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translatable_language_list() {
$languages = \Drupal::languageManager()->getLanguages();
if (!locale_is_translatable('en')) {
@@ -443,30 +442,6 @@ function locale_system_file_system_settings_submit(&$form, FormStateInterface $f
}
/**
- * Implements hook_preprocess_HOOK() for node templates.
- */
-function locale_preprocess_node(&$variables): void {
- /** @var \Drupal\node\NodeInterface $node */
- $node = $variables['node'];
- if ($node->language()->getId() != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
- $interface_language = \Drupal::languageManager()->getCurrentLanguage();
-
- $node_language = $node->language();
- if ($node_language->getId() != $interface_language->getId()) {
- // If the node language was different from the page language, we should
- // add markup to identify the language. Otherwise the page language is
- // inherited.
- $variables['attributes']['lang'] = $node_language->getId();
- if ($node_language->getDirection() != $interface_language->getDirection()) {
- // If text direction is different form the page's text direction, add
- // direction information as well.
- $variables['attributes']['dir'] = $node_language->getDirection();
- }
- }
- }
-}
-
-/**
* Gets current translation status from the {locale_file} table.
*
* @return array
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index e016a1a99a3..aef8c5f6fe5 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -4,7 +4,7 @@
* @file
*/
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Link;
use Drupal\Core\Url;
@@ -22,7 +22,7 @@ use Drupal\Core\Url;
*
* @see \Drupal\locale\Form\TranslationStatusForm
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function template_preprocess_locale_translation_update_info(array &$variables): void {
foreach ($variables['updates'] as $update) {
$variables['modules'][] = $update['name'];
diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc
index 7f48a5d3fa0..c82ba2e8666 100644
--- a/core/modules/locale/locale.translation.inc
+++ b/core/modules/locale/locale.translation.inc
@@ -4,7 +4,7 @@
* @file
*/
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\StreamWrapper\StreamWrapperManager;
/**
@@ -55,7 +55,7 @@ const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1;
*
* @see locale_translation_build_projects()
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function locale_translation_get_projects(array $project_names = []) {
$projects = &drupal_static(__FUNCTION__, []);
diff --git a/core/modules/locale/src/Hook/LocaleThemeHooks.php b/core/modules/locale/src/Hook/LocaleThemeHooks.php
new file mode 100644
index 00000000000..d1e438f50ac
--- /dev/null
+++ b/core/modules/locale/src/Hook/LocaleThemeHooks.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Drupal\locale\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+use Drupal\Core\Language\LanguageInterface;
+use Drupal\Core\Language\LanguageManagerInterface;
+
+/**
+ * Hook implementations for locale.
+ */
+class LocaleThemeHooks {
+
+ public function __construct(
+ protected readonly LanguageManagerInterface $languageManager,
+ ) {}
+
+ /**
+ * Implements hook_preprocess_HOOK() for node templates.
+ */
+ #[Preprocess('node')]
+ public function preprocessNode(&$variables): void {
+ /** @var \Drupal\node\NodeInterface $node */
+ $node = $variables['node'];
+ if ($node->language()->getId() != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
+ $interface_language = $this->languageManager->getCurrentLanguage();
+
+ $node_language = $node->language();
+ if ($node_language->getId() != $interface_language->getId()) {
+ // If the node language was different from the page language, we should
+ // add markup to identify the language. Otherwise the page language is
+ // inherited.
+ $variables['attributes']['lang'] = $node_language->getId();
+ if ($node_language->getDirection() != $interface_language->getDirection()) {
+ // If text direction is different form the page's text direction, add
+ // direction information as well.
+ $variables['attributes']['dir'] = $node_language->getDirection();
+ }
+ }
+ }
+ }
+
+}
diff --git a/core/modules/media/media.install b/core/modules/media/media.install
index f0acbf482da..48ed664fdef 100644
--- a/core/modules/media/media.install
+++ b/core/modules/media/media.install
@@ -8,7 +8,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\FileExists;
use Drupal\Core\File\FileSystemInterface;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Url;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
@@ -112,7 +112,7 @@ function media_requirements($phase): array {
/**
* Implements hook_install().
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function media_install(): void {
$source = \Drupal::service('extension.list.module')->getPath('media') . '/images/icons';
$destination = \Drupal::config('media.settings')->get('icon_base_uri');
diff --git a/core/modules/media/media.module b/core/modules/media/media.module
index 537cbee1862..dbf031d16a9 100644
--- a/core/modules/media/media.module
+++ b/core/modules/media/media.module
@@ -5,7 +5,7 @@
*/
use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElementBase;
use Drupal\Core\Template\Attribute;
@@ -23,7 +23,6 @@ use Drupal\Core\Url;
* - name: The label for the media item.
* - view_mode: View mode; e.g., 'full', 'teaser', etc.
*/
-#[StopProceduralHookScan]
function template_preprocess_media(array &$variables): void {
$variables['media'] = $variables['elements']['#media'];
$variables['view_mode'] = $variables['elements']['#view_mode'];
@@ -74,6 +73,7 @@ function media_preprocess_media_reference_help(&$variables): void {
* @internal
* This function is internal and may be removed in a minor release.
*/
+#[ProceduralHookScanStop]
function _media_get_add_url($allowed_bundles) {
$access_handler = \Drupal::entityTypeManager()->getAccessControlHandler('media');
$create_bundles = array_filter($allowed_bundles, [$access_handler, 'createAccess']);
diff --git a/core/modules/media_library/media_library.services.yml b/core/modules/media_library/media_library.services.yml
index 510769de9d6..7c0d2131601 100644
--- a/core/modules/media_library/media_library.services.yml
+++ b/core/modules/media_library/media_library.services.yml
@@ -1,5 +1,5 @@
parameters:
- media_library.hooks_converted: true
+ media_library.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/menu_link_content/menu_link_content.services.yml b/core/modules/menu_link_content/menu_link_content.services.yml
index 63d3867b1ad..e1a01a283f9 100644
--- a/core/modules/menu_link_content/menu_link_content.services.yml
+++ b/core/modules/menu_link_content/menu_link_content.services.yml
@@ -1,2 +1,2 @@
parameters:
- menu_link_content.hooks_converted: true
+ menu_link_content.skip_procedural_hook_scan: true
diff --git a/core/modules/menu_ui/menu_ui.services.yml b/core/modules/menu_ui/menu_ui.services.yml
index 962a86b9c3d..45682dc6e4d 100644
--- a/core/modules/menu_ui/menu_ui.services.yml
+++ b/core/modules/menu_ui/menu_ui.services.yml
@@ -1,5 +1,5 @@
parameters:
- menu_ui.hooks_converted: true
+ menu_ui.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/migrate/migrate.services.yml b/core/modules/migrate/migrate.services.yml
index 2af458d0827..8b2e4028571 100644
--- a/core/modules/migrate/migrate.services.yml
+++ b/core/modules/migrate/migrate.services.yml
@@ -1,5 +1,5 @@
parameters:
- migrate.hooks_converted: true
+ migrate.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/migrate_drupal/migrate_drupal.services.yml b/core/modules/migrate_drupal/migrate_drupal.services.yml
index e0d16a99459..358992f62df 100644
--- a/core/modules/migrate_drupal/migrate_drupal.services.yml
+++ b/core/modules/migrate_drupal/migrate_drupal.services.yml
@@ -1,5 +1,5 @@
parameters:
- migrate_drupal.hooks_converted: true
+ migrate_drupal.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml b/core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml
index 59ef9f3a1de..d4cd82212c5 100644
--- a/core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml
+++ b/core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml
@@ -1,5 +1,5 @@
parameters:
- migrate_drupal_ui.hooks_converted: true
+ migrate_drupal_ui.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index e2b0fcccb2e..4ee3c48a00b 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -257,30 +257,6 @@ function node_preprocess_block(&$variables): void {
}
/**
- * Implements hook_preprocess_HOOK() for node field templates.
- */
-function node_preprocess_field__node(&$variables): void {
- // Set a variable 'is_inline' in cases where inline markup is required,
- // without any block elements such as <div>.
-
- if ($variables['element']['#is_page_title'] ?? FALSE) {
- // Page title is always inline because it will be displayed inside <h1>.
- $variables['is_inline'] = TRUE;
- }
- elseif (in_array($variables['field_name'], ['created', 'uid', 'title'], TRUE)) {
- // Display created, uid and title fields inline because they will be
- // displayed inline by node.html.twig. Skip this if the field
- // display is configurable and skipping has been enabled.
- // @todo Delete as part of https://www.drupal.org/node/3015623
-
- /** @var \Drupal\node\NodeInterface $node */
- $node = $variables['element']['#object'];
- $skip_custom_preprocessing = $node->getEntityType()->get('enable_base_field_custom_preprocess_skipping');
- $variables['is_inline'] = !$skip_custom_preprocessing || !$node->getFieldDefinition($variables['field_name'])->isDisplayConfigurable('view');
- }
-}
-
-/**
* Implements hook_theme_suggestions_HOOK().
*/
function node_theme_suggestions_node(array $variables): array {
diff --git a/core/modules/node/src/Hook/NodeThemeHooks.php b/core/modules/node/src/Hook/NodeThemeHooks.php
new file mode 100644
index 00000000000..7ee443c458f
--- /dev/null
+++ b/core/modules/node/src/Hook/NodeThemeHooks.php
@@ -0,0 +1,38 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\node\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+
+/**
+ * Hook implementations for the node module.
+ */
+class NodeThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK() for node field templates.
+ */
+ #[Preprocess('field__node')]
+ public function preprocessFieldNode(&$variables): void {
+ // Set a variable 'is_inline' in cases where inline markup is required,
+ // without any block elements such as <div>.
+ if ($variables['element']['#is_page_title'] ?? FALSE) {
+ // Page title is always inline because it will be displayed inside <h1>.
+ $variables['is_inline'] = TRUE;
+ }
+ elseif (in_array($variables['field_name'], ['created', 'uid', 'title'], TRUE)) {
+ // Display created, uid and title fields inline because they will be
+ // displayed inline by node.html.twig. Skip this if the field
+ // display is configurable and skipping has been enabled.
+ // @todo Delete as part of https://www.drupal.org/node/3015623
+
+ /** @var \Drupal\node\NodeInterface $node */
+ $node = $variables['element']['#object'];
+ $skip_custom_preprocessing = $node->getEntityType()->get('enable_base_field_custom_preprocess_skipping');
+ $variables['is_inline'] = !$skip_custom_preprocessing || !$node->getFieldDefinition($variables['field_name'])->isDisplayConfigurable('view');
+ }
+ }
+
+}
diff --git a/core/modules/options/options.services.yml b/core/modules/options/options.services.yml
index b3734c763b1..dbce14350f8 100644
--- a/core/modules/options/options.services.yml
+++ b/core/modules/options/options.services.yml
@@ -1,2 +1,2 @@
parameters:
- options.hooks_converted: true
+ options.skip_procedural_hook_scan: true
diff --git a/core/modules/path/path.services.yml b/core/modules/path/path.services.yml
index c500d12fbee..ce638d5e3ed 100644
--- a/core/modules/path/path.services.yml
+++ b/core/modules/path/path.services.yml
@@ -1,2 +1,2 @@
parameters:
- path.hooks_converted: true
+ path.skip_procedural_hook_scan: true
diff --git a/core/modules/responsive_image/responsive_image.services.yml b/core/modules/responsive_image/responsive_image.services.yml
index c382d256722..a145f1dad9e 100644
--- a/core/modules/responsive_image/responsive_image.services.yml
+++ b/core/modules/responsive_image/responsive_image.services.yml
@@ -1,2 +1,2 @@
parameters:
- responsive_image.hooks_converted: true
+ responsive_image.skip_procedural_hook_scan: false
diff --git a/core/modules/rest/rest.services.yml b/core/modules/rest/rest.services.yml
index aa249ed3782..cb19a18e1ae 100644
--- a/core/modules/rest/rest.services.yml
+++ b/core/modules/rest/rest.services.yml
@@ -1,5 +1,5 @@
parameters:
- rest.hooks_converted: true
+ rest.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml
index 9dc3a849ce9..9629e55d652 100644
--- a/core/modules/serialization/serialization.services.yml
+++ b/core/modules/serialization/serialization.services.yml
@@ -1,5 +1,5 @@
parameters:
- serialization.hooks_converted: true
+ serialization.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/settings_tray/settings_tray.services.yml b/core/modules/settings_tray/settings_tray.services.yml
index b09ec37f1af..8ff9184774e 100644
--- a/core/modules/settings_tray/settings_tray.services.yml
+++ b/core/modules/settings_tray/settings_tray.services.yml
@@ -1,5 +1,5 @@
parameters:
- settings_tray.hooks_converted: true
+ settings_tray.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/shortcut/shortcut.services.yml b/core/modules/shortcut/shortcut.services.yml
index 00671a667b5..fdd4bc85c21 100644
--- a/core/modules/shortcut/shortcut.services.yml
+++ b/core/modules/shortcut/shortcut.services.yml
@@ -1,5 +1,5 @@
parameters:
- shortcut.hooks_converted: true
+ shortcut.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/syslog/syslog.services.yml b/core/modules/syslog/syslog.services.yml
index 3aaa962709c..8892ab797ee 100644
--- a/core/modules/syslog/syslog.services.yml
+++ b/core/modules/syslog/syslog.services.yml
@@ -1,5 +1,5 @@
parameters:
- syslog.hooks_converted: true
+ syslog.skip_procedural_hook_scan: true
services:
_defaults:
diff --git a/core/modules/system/tests/modules/hook_collector_skip_procedural/hook_collector_skip_procedural.services.yml b/core/modules/system/tests/modules/hook_collector_skip_procedural/hook_collector_skip_procedural.services.yml
index 205fd7c2b67..2309835abaa 100644
--- a/core/modules/system/tests/modules/hook_collector_skip_procedural/hook_collector_skip_procedural.services.yml
+++ b/core/modules/system/tests/modules/hook_collector_skip_procedural/hook_collector_skip_procedural.services.yml
@@ -1,2 +1,2 @@
parameters:
- hook_collector_skip_procedural.hooks_converted: true
+ hook_collector_skip_procedural.skip_procedural_hook_scan: true
diff --git a/core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module b/core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module
index e7b4bf3f682..31bc606d37e 100644
--- a/core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module
+++ b/core/modules/system/tests/modules/hook_collector_skip_procedural_attribute/hook_collector_skip_procedural_attribute.module
@@ -7,7 +7,7 @@
declare(strict_types=1);
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
/**
* This implements a hook and should be picked up.
@@ -25,7 +25,7 @@ function hook_collector_skip_procedural_attribute_cache_flush(): void {
* This attribute should stop all procedural hooks after.
* We implement on behalf of other modules so we can pick them up.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function hook_collector_on_behalf_procedural_cache_flush(): void {
// Set a global value we can check in test code.
$GLOBALS['procedural_attribute_skip_has_attribute'] = 'procedural_attribute_skip_has_attribute';
diff --git a/core/modules/system/tests/modules/module_test_oop_preprocess/module_test_oop_preprocess.info.yml b/core/modules/system/tests/modules/module_test_oop_preprocess/module_test_oop_preprocess.info.yml
new file mode 100644
index 00000000000..c3d2e98f6f4
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test_oop_preprocess/module_test_oop_preprocess.info.yml
@@ -0,0 +1,5 @@
+name: test oop preprocess functions
+type: module
+description: 'Test module used to test oop preprocess hooks are executed.'
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
new file mode 100644
index 00000000000..1cbb9e6b422
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test_oop_preprocess/src/Hook/ModuleTestOopPreprocessThemeHooks.php
@@ -0,0 +1,24 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\module_test_oop_preprocess\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+
+/**
+ * Hook implementations for module_test_oop_preprocess.
+ */
+class ModuleTestOopPreprocessThemeHooks {
+
+ #[Preprocess]
+ public function rootPreprocess($arg): mixed {
+ return $arg;
+ }
+
+ #[Preprocess('test')]
+ public function preprocessTest($arg): mixed {
+ return $arg;
+ }
+
+}
diff --git a/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.info.yml b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.info.yml
new file mode 100644
index 00000000000..2cc1e7840d5
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.info.yml
@@ -0,0 +1,5 @@
+name: test procedural preprocess functions
+type: module
+description: 'Test module used to test procedural preprocess hooks are executed.'
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module
new file mode 100644
index 00000000000..1e7665b412d
--- /dev/null
+++ b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * @file
+ * Test module.
+ */
+
+declare(strict_types=1);
+
+function template_preprocess_test($arg): mixed {
+ return $arg;
+}
+
+function module_test_procedural_preprocess_preprocess($arg): mixed {
+ return $arg;
+}
+
+function module_test_procedural_preprocess_preprocess_test($arg): mixed {
+ return $arg;
+}
diff --git a/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
new file mode 100644
index 00000000000..fc48756de51
--- /dev/null
+++ b/core/modules/system/tests/modules/theme_test/src/Hook/ThemeTestThemeHooks.php
@@ -0,0 +1,22 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Drupal\theme_test\Hook;
+
+use Drupal\Core\Hook\Attribute\Preprocess;
+
+/**
+ * Hook implementations for theme_test.
+ */
+class ThemeTestThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK().
+ */
+ #[Preprocess('theme_test_preprocess_suggestions__monkey')]
+ public function preprocessTestSuggestions(&$variables): void {
+ $variables['foo'] = 'Monkey';
+ }
+
+}
diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module
index aabef2b6c4a..72c92352b61 100644
--- a/core/modules/system/tests/modules/theme_test/theme_test.module
+++ b/core/modules/system/tests/modules/theme_test/theme_test.module
@@ -32,13 +32,6 @@ function theme_test_preprocess_theme_test_preprocess_suggestions(&$variables): v
}
/**
- * Tests a module overriding a default hook with a suggestion.
- */
-function theme_test_preprocess_theme_test_preprocess_suggestions__monkey(&$variables): void {
- $variables['foo'] = 'Monkey';
-}
-
-/**
* Prepares variables for test render element templates.
*
* Default template: theme-test-render-element.html.twig.
diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
index eccaceaeca7..5520b49f762 100644
--- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
+++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php
@@ -362,6 +362,56 @@ class ModuleHandlerTest extends KernelTestBase {
}
/**
+ * Tests procedural preprocess functions.
+ */
+ public function testProceduralPreprocess(): void {
+ $this->moduleInstaller()->install(['module_test_procedural_preprocess']);
+ $preprocess_function = [];
+ $preprocess_invoke = [];
+ $prefix = 'module_test_procedural_preprocess';
+ $hook = 'test';
+ if ($this->moduleHandler()->hasImplementations('preprocess', [$prefix], TRUE)) {
+ $function = "{$prefix}_preprocess";
+ $preprocess_function[] = $function;
+ $preprocess_invoke[$function] = ['module' => $prefix, 'hook' => 'preprocess'];
+ }
+ if ($this->moduleHandler()->hasImplementations('preprocess_' . $hook, [$prefix], TRUE)) {
+ $function = "{$prefix}_preprocess_{$hook}";
+ $preprocess_function[] = $function;
+ $preprocess_invoke[$function] = ['module' => $prefix, 'hook' => 'preprocess_' . $hook];
+ }
+
+ foreach ($preprocess_function as $function) {
+ $this->assertTrue($this->moduleHandler()->invoke(... $preprocess_invoke[$function], args: [TRUE]), 'Procedural hook_preprocess runs.');
+ }
+ }
+
+ /**
+ * Tests Oop preprocess functions.
+ */
+ public function testOopPreprocess(): void {
+ $this->moduleInstaller()->install(['module_test_oop_preprocess']);
+ $preprocess_function = [];
+ $preprocess_invoke = [];
+ $prefix = 'module_test_oop_preprocess';
+ $hook = 'test';
+ if ($this->moduleHandler()->hasImplementations('preprocess', [$prefix], TRUE)) {
+ $function = "{$prefix}_preprocess";
+ $preprocess_function[] = $function;
+ $preprocess_invoke[$function] = ['module' => $prefix, 'hook' => 'preprocess'];
+ }
+ if ($this->moduleHandler()->hasImplementations('preprocess_' . $hook, [$prefix], TRUE)) {
+ $function = "{$prefix}_preprocess_{$hook}";
+ $preprocess_function[] = $function;
+ $preprocess_invoke[$function] = ['module' => $prefix, 'hook' => 'preprocess_' . $hook];
+ }
+
+ foreach ($preprocess_function as $function) {
+ $this->assertTrue($this->moduleHandler()->invoke(... $preprocess_invoke[$function], args: [TRUE]), 'Procedural hook_preprocess runs.');
+ }
+ }
+
+ /**
* Returns the ModuleHandler.
*
* @return \Drupal\Core\Extension\ModuleHandlerInterface
diff --git a/core/modules/text/text.services.yml b/core/modules/text/text.services.yml
index 20764124576..720e0fe820b 100644
--- a/core/modules/text/text.services.yml
+++ b/core/modules/text/text.services.yml
@@ -1,2 +1,2 @@
parameters:
- text.hooks_converted: true
+ text.skip_procedural_hook_scan: true
diff --git a/core/modules/toolbar/toolbar.services.yml b/core/modules/toolbar/toolbar.services.yml
index 23852026720..67a1b071916 100644
--- a/core/modules/toolbar/toolbar.services.yml
+++ b/core/modules/toolbar/toolbar.services.yml
@@ -1,5 +1,5 @@
parameters:
- toolbar.hooks_converted: true
+ toolbar.skip_procedural_hook_scan: false
services:
_defaults:
diff --git a/core/modules/update/update.authorize.inc b/core/modules/update/update.authorize.inc
index 8a2ba55d667..64f8fe7b014 100644
--- a/core/modules/update/update.authorize.inc
+++ b/core/modules/update/update.authorize.inc
@@ -5,7 +5,7 @@
*/
use Drupal\Core\Batch\BatchBuilder;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Updater\UpdaterException;
use Drupal\Core\Url;
@@ -31,7 +31,7 @@ use Drupal\Core\Url;
* an instance of \Symfony\Component\HttpFoundation\Response the calling code
* should use that response for the current page request.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function update_authorize_run_update($filetransfer, $projects) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc
index 1ea781a974b..05c6565ce19 100644
--- a/core/modules/update/update.compare.inc
+++ b/core/modules/update/update.compare.inc
@@ -5,7 +5,7 @@
*/
use Drupal\Core\Extension\ExtensionVersion;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Utility\Error;
use Drupal\update\ProjectRelease;
use Drupal\update\UpdateFetcherInterface;
@@ -23,7 +23,7 @@ use Drupal\update\ProjectCoreCompatibility;
* Array of project information from
* \Drupal\update\UpdateManager::getProjects().
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function update_process_project_info(&$projects): void {
foreach ($projects as $key => $project) {
// Assume an official release until we see otherwise.
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index 2c828cc3e7f..296dfbd3d06 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -4,7 +4,7 @@
* @file
*/
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\update\UpdateManagerInterface;
/**
@@ -16,7 +16,7 @@ use Drupal\update\UpdateManagerInterface;
*
* @see update_requirements()
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function _update_cron_notify(): void {
$update_config = \Drupal::config('update.settings');
\Drupal::moduleHandler()->loadInclude('update', 'install');
diff --git a/core/modules/update/update.install b/core/modules/update/update.install
index 2981ea91373..3ad55265aab 100644
--- a/core/modules/update/update.install
+++ b/core/modules/update/update.install
@@ -5,7 +5,7 @@
* Install, update, and uninstall functions for the Update Status module.
*/
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\update\ProjectSecurityData;
@@ -74,7 +74,7 @@ function update_requirements($phase): array {
/**
* Implements hook_install().
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function update_install(): void {
$queue = \Drupal::queue('update_fetch_tasks', TRUE);
$queue->createQueue();
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index 46611f85cd8..f4b18321002 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -7,7 +7,7 @@
use Drupal\Core\File\Exception\FileException;
use Drupal\Core\File\Exception\InvalidStreamWrapperException;
use Drupal\Core\File\FileExists;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Psr\Http\Client\ClientExceptionInterface;
/**
@@ -24,7 +24,7 @@ use Psr\Http\Client\ClientExceptionInterface;
* workflow, or FALSE if we've hit a fatal configuration and must halt the
* workflow.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function _update_manager_check_backends(&$form, $operation) {
@trigger_error(__METHOD__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. There is no replacement. Use composer to manage the code for your site. See https://www.drupal.org/node/3512364', E_USER_DEPRECATED);
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index c4366293a05..e06ac21ea31 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -5,7 +5,7 @@
*/
use Drupal\Core\File\Exception\FileException;
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
+use Drupal\Core\Hook\Attribute\ProceduralHookScanStop;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Site\Settings;
@@ -15,7 +15,7 @@ use Drupal\update\UpdateManagerInterface;
/**
* Returns a warning message when there is no data about available updates.
*/
-#[StopProceduralHookScan]
+#[ProceduralHookScanStop]
function _update_no_data() {
$destination = \Drupal::destination()->getAsArray();
return t('No update information available. <a href=":run_cron">Run cron</a> or <a href=":check_manually">check manually</a>.', [
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index 615e54b35b2..75957754bd8 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -4,7 +4,6 @@
* @file
*/
-use Drupal\Core\Hook\Attribute\StopProceduralHookScan;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\update\ProjectRelease;
@@ -20,7 +19,6 @@ use Drupal\update\UpdateManagerInterface;
* An associative array containing:
* - data: An array of data about each project's status.
*/
-#[StopProceduralHookScan]
function template_preprocess_update_report(&$variables): void {
$data = isset($variables['data']) && is_array($variables['data']) ? $variables['data'] : [];
diff --git a/core/modules/workflows/workflows.services.yml b/core/modules/workflows/workflows.services.yml
index 868807dfc63..ad50650e6db 100644
--- a/core/modules/workflows/workflows.services.yml
+++ b/core/modules/workflows/workflows.services.yml
@@ -1,5 +1,5 @@
parameters:
- workflows.hooks_converted: true
+ workflows.skip_procedural_hook_scan: true
services:
_defaults: