Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_suite_bootstrap
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
ui_suite_bootstrap
Merge requests
!193
Resolve
#3403816
"Simplify dark options"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve
#3403816
"Simplify dark options"
issue/ui_suite_bootstrap-3403816:3403816-simplify-dark-options
into
5.0.x
Overview
0
Commits
2
Pipelines
2
Changes
7
Merged
Florent Torregrosa
requested to merge
issue/ui_suite_bootstrap-3403816:3403816-simplify-dark-options
into
5.0.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
7
Expand
Closes
#3403816
0
0
Merge request reports
Compare
5.0.x
5.0.x (base)
and
latest version
latest version
770a7738
2 commits,
1 year ago
7 files
+
31
−
94
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
src/HookHandler/PreprocessPatternNavbar.php deleted
100644 → 0
+
0
−
65
Options
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\ui_suite_bootstrap\HookHandler
;
use
Drupal\Core\Render\Element
;
/**
* Handle variables needed for the pattern.
*/
class
PreprocessPatternNavbar
{
/**
* Length of the word dark.
*/
public
const
DARK_LENGTH
=
4
;
/**
* Pattern fields where render elements will be injected.
*/
public
const
REGIONS_FIELDS
=
[
'navigation'
,
'navigation_collapsible'
,
];
/**
* Handle variables needed for the pattern.
*
* @param array $variables
* The preprocessed variables.
*/
public
function
preprocess
(
array
&
$variables
):
void
{
if
(
\substr
(
$variables
[
'variant'
],
0
,
self
::
DARK_LENGTH
)
===
'dark'
)
{
foreach
(
self
::
REGIONS_FIELDS
as
$region
)
{
if
(
isset
(
$variables
[
$region
]))
{
$this
->
addDarkSetting
(
$variables
[
$region
]);
}
}
}
}
/**
* Add dark setting to navbar_nav pattern.
*
* @param array $item
* The render element to parse.
*/
protected
function
addDarkSetting
(
array
&
$item
):
void
{
if
(
isset
(
$item
[
'#type'
])
&&
\in_array
(
$item
[
'#type'
],
[
'pattern'
,
'pattern_preview'
],
TRUE
)
&&
$item
[
'#id'
]
==
'navbar_nav'
)
{
$item
[
'#dark'
]
=
TRUE
;
// Stop recursion when a navbar_nav is found, no need to enter in it.
return
;
}
$children
=
Element
::
children
(
$item
);
foreach
(
$children
as
$key
)
{
$this
->
addDarkSetting
(
$item
[
$key
]);
}
}
}
Loading