-
Notifications
You must be signed in to change notification settings - Fork 2
/
cd_core.module
54 lines (47 loc) · 1.58 KB
/
cd_core.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
<?php
/**
* @file
* Contains code for Clarodist Core module.
*/
use Drupal\Core\Render\Element;
use Drupal\Component\Utility\Html;
/**
* Implements hook_entity_type_alter().
*/
function cd_core_entity_type_alter(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
if (isset($entity_types['contact_form'])) {
$entity_types['contact_form']->setHandlerClass('access', '\Drupal\cd_core\ContactFormAccessControlHandler');
}
}
/**
* Prepares variables for the side_by_side layout template.
*
* Default template: layout--side-by-side.html.twig.
*
* See the layout--side-by-side.html.twig template for the list of variables.
*/
function template_preprocess_layout__side_by_side(&$variables) {
$variables['content']['main']['#pre_render'][] = function($region) {
foreach (Element::children($region) as $item_key) {
$region[$item_key]['#theme_wrappers']['container__sbs_item'] = [
'#attributes' => ['data-region' => $region[$item_key]['#group'] ?? 'main'],
];
}
return $region;
};
}
/**
* Implements hook_preprocess_HOOK() for container__sbs_items.
*
* Removes possibly duped attributes (classes or mainly ids) from the container
* by overriding the provided array.
*/
function cd_core_preprocess_container__sbs_item(&$variables) {
$region = !empty($variables['attributes']['data-region']) ?
$variables['attributes']['data-region'] : FALSE;
$variables['attributes'] = ['class' => ['sbs-layout__item']];
if ($region) {
$variables['attributes']['class'][] = Html::getClass('sbs-layout__item--' . $region);
}
}