Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
f6a0cef1
Commit
f6a0cef1
authored
4 months ago
by
nlighteneddesign
Browse files
Options
Downloads
Patches
Plain Diff
Address comments on moduleFinder
parent
e8652d41
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/lib/Drupal/Core/Hook/HookCollectorPass.php
+11
-7
11 additions, 7 deletions
core/lib/Drupal/Core/Hook/HookCollectorPass.php
with
11 additions
and
7 deletions
core/lib/Drupal/Core/Hook/HookCollectorPass.php
+
11
−
7
View file @
f6a0cef1
...
@@ -125,7 +125,7 @@ public function process(ContainerBuilder $container): array {
...
@@ -125,7 +125,7 @@ public function process(ContainerBuilder $container): array {
// Store the implementation details for registering the hook.
// Store the implementation details for registering the hook.
$implementations
[
$hookAttribute
->
hook
][
$hookAttribute
->
module
][
$class
][
$hookAttribute
->
method
]
=
$hookAttribute
->
method
;
$implementations
[
$hookAttribute
->
hook
][
$hookAttribute
->
module
][
$class
][
$hookAttribute
->
method
]
=
$hookAttribute
->
method
;
// Reverse lookup for modules implementing hooks.
// Reverse lookup for modules implementing hooks.
$moduleFinder
[
$class
][
$hookAttribute
->
method
]
=
$hookAttribute
->
module
;
$moduleFinder
[
$class
][
$hookAttribute
->
method
]
[
$hookAttribute
->
hook
]
=
$hookAttribute
->
module
;
if
(
$hookAttribute
->
order
)
{
if
(
$hookAttribute
->
order
)
{
$hookOrderOperations
[]
=
$hookAttribute
;
$hookOrderOperations
[]
=
$hookAttribute
;
}
}
...
@@ -139,7 +139,7 @@ public function process(ContainerBuilder $container): array {
...
@@ -139,7 +139,7 @@ public function process(ContainerBuilder $container): array {
// registration to ensure the hook it is removing has already been
// registration to ensure the hook it is removing has already been
// discovered.
// discovered.
foreach
(
$processAfter
[
RemoveHook
::
class
]
as
$removeHook
)
{
foreach
(
$processAfter
[
RemoveHook
::
class
]
as
$removeHook
)
{
if
(
$module
=
(
$moduleFinder
[
$removeHook
->
class
][
$removeHook
->
method
]
??
''
))
{
if
(
$module
=
(
$moduleFinder
[
$removeHook
->
class
][
$removeHook
->
method
]
[
$removeHook
->
hook
]
??
''
))
{
unset
(
$implementations
[
$removeHook
->
hook
][
$module
][
$removeHook
->
class
][
$removeHook
->
method
]);
unset
(
$implementations
[
$removeHook
->
hook
][
$module
][
$removeHook
->
class
][
$removeHook
->
method
]);
// A module can implement a hook more than one time so confirm no
// A module can implement a hook more than one time so confirm no
// more implementations before removing from the
// more implementations before removing from the
...
@@ -251,10 +251,10 @@ protected static function registerImplementations(ContainerBuilder $container, H
...
@@ -251,10 +251,10 @@ protected static function registerImplementations(ContainerBuilder $container, H
* Lists of extra hooks to order together with, keyed by hook name.
* Lists of extra hooks to order together with, keyed by hook name.
* @param array<string, array<string, array<class-string, list<string>>>> $implementations
* @param array<string, array<string, array<class-string, list<string>>>> $implementations
* Hook implementations, as method names by hook, module and class.
* Hook implementations, as method names by hook, module and class.
* @param array<class-string, array<string, string>> $moduleFinder
* @param array<class-string,
array<
array<string, string>>
>
$moduleFinder
* Lookup map to find the module for each hook implementation.
* Lookup map to find the module for each hook implementation.
* Array keys are the class
and
method
of the hook implementation, array
* Array keys are the class
,
method
, and hook, array values are module
*
values are module
names.
* names.
* The module name can be different from the module the class is in,
* The module name can be different from the module the class is in,
* because an implementation can be on behalf of another module.
* because an implementation can be on behalf of another module.
*/
*/
...
@@ -577,8 +577,9 @@ protected static function addTagToDefinition(Definition $definition, string|int
...
@@ -577,8 +577,9 @@ protected static function addTagToDefinition(Definition $definition, string|int
* The container.
* The container.
* @param list<array{class-string, string}> $classesAndMethods
* @param list<array{class-string, string}> $classesAndMethods
* A list of class-and-method pairs.
* A list of class-and-method pairs.
* @param array<class-string, array<string, string>> $moduleFinder
* @param array<class-string, array<array<string, string>>> $moduleFinder
* Module names by class and method of hook implementations.
* Array keys are the class, method, and hook, array values are module
* names.
* @param string $combinedHook
* @param string $combinedHook
* A string made form list of hooks separated by :
* A string made form list of hooks separated by :
*/
*/
...
@@ -588,6 +589,9 @@ protected static function registerComplexHookImplementations(ContainerBuilder $c
...
@@ -588,6 +589,9 @@ protected static function registerComplexHookImplementations(ContainerBuilder $c
foreach
(
$classesAndMethods
as
[
$class
,
$method
])
{
foreach
(
$classesAndMethods
as
[
$class
,
$method
])
{
// Ordering against not installed modules is possible.
// Ordering against not installed modules is possible.
if
(
isset
(
$moduleFinder
[
$class
][
$method
]))
{
if
(
isset
(
$moduleFinder
[
$class
][
$method
]))
{
if
(
count
(
array_unique
(
$moduleFinder
[
$class
][
$method
]))
>
1
)
{
throw
new
\LogicException
(
'Complex ordering can only work when all implementations on a single method are for the same module.'
);
}
$map
[
$combinedHook
][
$class
][
$method
]
=
$moduleFinder
[
$class
][
$method
];
$map
[
$combinedHook
][
$class
][
$method
]
=
$moduleFinder
[
$class
][
$method
];
$priority
=
self
::
addTagToDefinition
(
$container
->
findDefinition
(
$class
),
$combinedHook
,
$method
,
$priority
);
$priority
=
self
::
addTagToDefinition
(
$container
->
findDefinition
(
$class
),
$combinedHook
,
$method
,
$priority
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment