Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bootstrapper
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
bootstrapper
Commits
b16d0446
Commit
b16d0446
authored
9 months ago
by
Mykola Antoshchuk
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3443379
by Mykola Antoshchuk: Drupal 10 compatibility fixes
parent
86d67de6
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
bootstrapper.theme
+55
-10
55 additions, 10 deletions
bootstrapper.theme
templates/form/select.html.twig
+2
-2
2 additions, 2 deletions
templates/form/select.html.twig
with
57 additions
and
12 deletions
bootstrapper.theme
+
55
−
10
View file @
b16d0446
...
...
@@ -73,10 +73,8 @@ function bootstrapper_html_head_alter(&$header) {
* @param $hook
*/
function
bootstrapper_theme_suggestions_alter
(
array
&
$suggestions
,
array
&
$variables
,
$hook
)
{
// Page suggestions.
if
(
$hook
==
'page'
)
{
// Page by route name.
$suggestions
[]
=
$hook
.
'__'
.
str_replace
(
'.'
,
'_'
,
\Drupal
::
routeMatch
()
->
getRouteName
());
...
...
@@ -105,23 +103,38 @@ function bootstrapper_theme_suggestions_alter(array &$suggestions, array &$varia
array_splice
(
$suggestions
,
2
,
0
,
$hook
.
'__'
.
'taxonomy__term'
.
'__'
.
$term
->
bundle
());
}
}
}
// Add page suggestions to regions to process them later in "region" suggestions.
$regions
=
\Drupal
::
theme
()
->
getActiveTheme
()
->
getRegions
();
foreach
(
$regions
as
$region
)
{
if
(
isset
(
$variables
[
'page'
][
$region
]))
{
$variables
[
'page'
][
$region
][
'#page_suggestions'
]
=
$suggestions
;
if
(
$hook
==
'fieldset'
)
{
$element_type
=
$variables
[
"element"
][
"#type"
]
??
''
;
$page_suggestions
=
system_theme_suggestions_page
([]);
if
(
isset
(
$page_suggestions
))
{
// Add region suggestions depending on page suggestions.
$fieldset_suggestions
=
[];
foreach
(
$page_suggestions
as
$page_suggestion
)
{
if
(
$suggestions
)
{
foreach
(
$suggestions
as
$region_suggestion
)
{
$fieldset_suggestions
[]
=
'fieldset__'
.
$page_suggestion
.
'__'
.
$fieldset_suggestions
.
'__'
.
$element_type
;
}
}
else
{
$fieldset_suggestions
[]
=
'fieldset__'
.
$page_suggestion
.
'__'
.
$element_type
;
}
}
$suggestions
=
array_merge
(
$suggestions
,
$fieldset_suggestions
);
}
}
// Region suggestions.
if
(
$hook
==
'region'
)
{
if
(
isset
(
$variables
[
'elements'
][
'#page_suggestions'
])
&&
$variables
[
'elements'
][
'#page_suggestions'
])
{
$page_suggestions
=
system_theme_suggestions_page
([]);
bootstrapper_getThemeSuggestions
(
$page_suggestions
,
$hook
);
if
(
isset
(
$page_suggestions
))
{
// Add region suggestions depending on page suggestions.
$region_suggestions
=
[];
foreach
(
$
variables
[
'elements'
][
'#
page_suggestions
'
]
as
$page_suggestion
)
{
foreach
(
$page_suggestions
as
$page_suggestion
)
{
foreach
(
$suggestions
as
$region_suggestion
)
{
$region_suggestions
[]
=
'region__'
.
$page_suggestion
.
'__'
.
$region_suggestion
;
}
...
...
@@ -275,3 +288,35 @@ function bootstrapper_preprocess(&$variables, $hook, $info) {
}
}
function
bootstrapper_getThemeSuggestions
(
&
$suggestions
,
$hook
)
{
// Page by route name.
$suggestions
[]
=
'page__'
.
str_replace
(
'.'
,
'_'
,
\Drupal
::
routeMatch
()
->
getRouteName
());
// Page by node type.
if
(
$node
=
\Drupal
::
request
()
->
attributes
->
get
(
'node'
))
{
// If the variable $node is string, suspecting it's a node ID,
// then load the node by ID.
if
(
is_string
(
$node
))
{
$node
=
\Drupal\node\Entity\Node
::
load
(
$node
);
}
if
(
$node
)
{
array_splice
(
$suggestions
,
1
,
0
,
'page__'
.
'node'
.
'__'
.
$node
->
bundle
());
}
}
// Page by taxonomy vocabulary type.
if
(
$term
=
\Drupal
::
request
()
->
attributes
->
get
(
'taxonomy_term'
))
{
// If the variable $taxonomy_term is string, suspecting it's a term ID,
// then load the term by ID.
if
(
is_string
(
$term
))
{
$term
=
\Drupal\taxonomy\Entity\Term
::
load
(
$term
);
}
if
(
$term
)
{
array_splice
(
$suggestions
,
2
,
0
,
'page__'
.
'taxonomy__term'
.
'__'
.
$term
->
bundle
());
}
}
}
This diff is collapsed.
Click to expand it.
templates/form/select.html.twig
+
2
−
2
View file @
b16d0446
...
...
@@ -10,7 +10,7 @@
* @see template_preprocess_select()
*/
#}
{%
spaceless
%}
{%
apply
spaceless
%}
<select
{{
attributes
}}
>
{%
for
option
in
options
%}
{%
if
option.type
==
'optgroup'
%}
...
...
@@ -24,4 +24,4 @@
{%
endif
%}
{%
endfor
%}
</select>
{%
end
spaceless
%}
{%
end
apply
%}
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