Skip to content

Commit c5df227

Browse files
committed
OEL-4322: Allow to keep ui_patterns v1.
1 parent c09ffb8 commit c5df227

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

composer.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"prefer-stable": true,
88
"require": {
99
"php": ">=8.1",
10-
"cweagans/composer-patches": "^1.7",
10+
"cweagans/composer-patches": "^2.0",
1111
"drupal/core": "^10.3 || ^11",
1212
"drupal/file_link": "^2.2",
13-
"drupal/ui_patterns": "^2.0",
14-
"drupal/ui_patterns_settings": "3.0.x-dev",
13+
"drupal/ui_patterns": "^1.0 || ^2.0",
14+
"drupal/ui_patterns_settings": "2.0 || 3.0.x-dev",
15+
"openeuropa/composer-dependent-patches": "^0.2.0",
1516
"openeuropa/ecl-twig-loader": "^4.0"
1617
},
1718
"require-dev": {
@@ -71,6 +72,17 @@
7172
"locations": {
7273
"web-root": "./build"
7374
}
75+
},
76+
"dependent-patches": {
77+
"drupal/ui_patterns_settings": [
78+
{
79+
"description": "Case mismatch between loaded and declared class names @see https://www.drupal.org/project/ui_patterns_settings/issues/3508198",
80+
"url": "https://www.drupal.org/files/issues/2025-02-21/3508198-case-mismatch.patch",
81+
"extra": {
82+
"version": ">=2.0 <3.0"
83+
}
84+
}
85+
]
7486
}
7587
},
7688
"config": {
@@ -81,6 +93,7 @@
8193
"dealerdirect/phpcodesniffer-composer-installer": true,
8294
"drupal/core-composer-scaffold": true,
8395
"ec-europa/toolkit-composer-plugin": true,
96+
"openeuropa/composer-dependent-patches": true,
8497
"php-http/discovery": false,
8598
"phpro/grumphp-shim": true,
8699
"phpstan/extension-installer": true,

includes/pattern.inc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@ function oe_bootstrap_theme_preprocess_pattern_offcanvas(array &$variables): voi
5959
$variables['offcanvas_id'] = $variables['attributes']['id'] ?? Html::getUniqueId('bcl_offcanvas');
6060
}
6161

62+
/**
63+
* Implements hook_preprocess_HOOK() for description list pattern.
64+
*/
65+
function oe_bootstrap_theme_preprocess_pattern_description_list(&$variables) {
66+
// Multiple terms can be passed for each item. Process all the entries to
67+
// add path and size to icons, if not yet specified.
68+
foreach ($variables['items'] as &$item) {
69+
// Allow to pass a single term, without forcing users to pass an array with
70+
// the "label" key in it. This covers for a bug in the BCL pattern.
71+
if (!is_array($item['term'])) {
72+
$item['term'] = [
73+
['label' => $item['term']],
74+
];
75+
continue;
76+
}
77+
78+
foreach ($item['term'] as &$term) {
79+
if (is_array($term) && !empty($term['icon'])) {
80+
// If the icon is not an array, the icon name has been passed.
81+
if (!is_array($term['icon'])) {
82+
$term['icon'] = [
83+
'name' => $term['icon'],
84+
];
85+
}
86+
$term['icon'] += [
87+
'size' => 'xs',
88+
'path' => $variables['bcl_icon_path'],
89+
];
90+
}
91+
}
92+
}
93+
}
94+
6295
/**
6396
* Implements hook_preprocess_HOOK().
6497
*/

0 commit comments

Comments
 (0)