-
Notifications
You must be signed in to change notification settings - Fork 0
/
iso3166.module
61 lines (54 loc) · 1.54 KB
/
iso3166.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @file
* The iso3166 module.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Element\RenderElement;
/**
* Implements hook_theme().
*/
function iso3166_theme() {
return [
'country' => [
'render element' => 'element',
],
'continent' => [
'render element' => 'element',
],
];
}
/**
* Prepares variables for iso3166 continent templates.
*
* Default template: continent.html.twig.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes.
*/
function template_preprocess_continent(array &$variables) {
$element = $variables['element'];
Element::setAttributes($element, ['id', 'name', 'size']);
RenderElement::setAttributes($element, ['form-select']);
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
}
/**
* Prepares variables for iso3166 country templates.
*
* Default template: country.html.twig.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #attributes.
*/
function template_preprocess_country(array &$variables) {
$element = $variables['element'];
Element::setAttributes($element, ['id', 'name', 'size']);
RenderElement::setAttributes($element, ['form-select']);
$variables['attributes'] = $element['#attributes'];
$variables['options'] = form_select_options($element);
}