Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
asset_injector
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
asset_injector
Merge requests
!13
Issue
#3387531
: Provide upgrade path for the "current_theme" condition
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3387531
: Provide upgrade path for the "current_theme" condition
issue/asset_injector-3387531:3387531-provide-upgrade-path
into
8.x-2.x
Overview
0
Commits
1
Pipelines
0
Changes
1
Open
codebymikey
requested to merge
issue/asset_injector-3387531:3387531-provide-upgrade-path
into
8.x-2.x
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
8.x-2.x
version 1
2123adb4
1 year ago
8.x-2.x (HEAD)
and
latest version
latest version
5c2531d2
1 commit,
1 year ago
version 1
2123adb4
1 commit,
1 year ago
1 file
+
51
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
asset_injector.post_update.php
+
51
−
0
Options
@@ -5,6 +5,8 @@
* Post update functions for the Asset Injector module.
*/
use
Drupal\Core\Render\Markup
;
/**
* Update node type conditions from "node_type" to "entity_bundle:node".
*/
@@ -38,3 +40,52 @@ function asset_injector_post_update_update_node_type_conditions() {
return
NULL
;
}
/**
* Attempt to normalize the "current_theme" conditions.
*/
function
asset_injector_post_update_normalize_current_theme_conditions
()
{
$updated_configs
=
[];
$unsupported_configs
=
[];
foreach
(
\Drupal
::
configFactory
()
->
listAll
(
'asset_injector.'
)
as
$asset_injector_config_name
)
{
$asset_injector_config
=
\Drupal
::
configFactory
()
->
getEditable
(
$asset_injector_config_name
);
// Load asset injector entities and normalize the "current_theme" condition.
if
(
$asset_injector_config
->
get
(
'id'
)
&&
$asset_injector_config
->
get
(
'conditions.current_theme'
))
{
$current_theme
=
$asset_injector_config
->
get
(
'conditions.current_theme'
);
if
(
isset
(
$current_theme
[
'theme'
])
&&
is_array
(
$current_theme
[
'theme'
]))
{
if
(
count
(
$current_theme
[
'theme'
])
<
2
)
{
$current_theme
[
'theme'
]
=
(
string
)
reset
(
$current_theme
[
'theme'
]);
$asset_injector_config
->
set
(
'conditions.current_theme'
,
$current_theme
)
->
save
(
TRUE
);
$updated_configs
[]
=
$asset_injector_config_name
;
}
else
{
$unsupported_configs
[]
=
$asset_injector_config_name
;
}
}
}
}
$output
=
[];
if
(
$updated_configs
)
{
$output
[]
=
t
(
'Normalized the "current_theme" condition on %config_names.'
,
[
'%config_names'
=>
implode
(
', '
,
$updated_configs
),
]);
}
if
(
$unsupported_configs
)
{
$output
[]
=
t
(
'Could not normalize the "current_theme" condition on %config_names.'
,
[
'%config_names'
=>
implode
(
', '
,
$unsupported_configs
),
]);
\Drupal
::
logger
(
'asset_injector'
)
->
warning
(
'Theme conditions are now only limited to a single theme per asset. Please review the theme condition settings for %config_names'
,
[
'%config_names'
=>
implode
(
', '
,
$unsupported_configs
),
]);
}
if
(
$output
)
{
return
Markup
::
create
(
implode
(
"
\n
"
,
$output
));
}
return
NULL
;
}
Loading