Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hux-3363433
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
hux-3363433
Commits
da13608a
Verified
Commit
da13608a
authored
3 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3257956
by dpi: Throw exception when an an unsupported Alter/Hook is implemented
parent
c182adad
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Attribute/Alter.php
+9
-0
9 additions, 0 deletions
src/Attribute/Alter.php
src/Attribute/Hook.php
+12
-0
12 additions, 0 deletions
src/Attribute/Hook.php
with
21 additions
and
0 deletions
src/Attribute/Alter.php
+
9
−
0
View file @
da13608a
...
...
@@ -21,6 +21,15 @@ class Alter {
)
{
assert
(
!
str_starts_with
(
$alter
,
'hook_'
));
assert
(
!
str_ends_with
(
$alter
,
'_alter'
));
if
(
in_array
(
$alter
,
[
// This hook is invoked by \Drupal\Core\Extension\ModuleHandler::alter.
'module_implements_alter'
,
],
TRUE
))
{
// If this alter becomes supported, and Hux is still throwing this
// exception, then you can temporarily extend this class and constructor
// to workaround this check.
throw
new
\Exception
(
$alter
.
' is an unsupported alter implementation.'
);
}
}
}
This diff is collapsed.
Click to expand it.
src/Attribute/Hook.php
+
12
−
0
View file @
da13608a
...
...
@@ -31,6 +31,18 @@ class Hook {
)
{
// Specifically look for 'hook_' at position zero.
assert
(
strpos
(
$hook
,
'hook_'
)
!==
0
);
if
(
in_array
(
$hook
,
[
// This hook is invoked by \Drupal\Core\Theme\Registry::processExtension.
// It is not converted to a moduleHandler->invoke* by the core patch since
// it needs to be able to invoke to module, theme engine, base theme
// engine, themes, etc.
'theme'
,
],
TRUE
))
{
// If this hook becomes supported, and Hux is still throwing this
// exception, then you can temporarily extend this class and constructor
// to workaround this check.
throw
new
\Exception
(
$hook
.
' is an unsupported hook implementation.'
);
}
}
}
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