-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdate_recur.module
91 lines (77 loc) · 2.71 KB
/
date_recur.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* @file
* Contains hooks for date_recur module.
*/
declare(strict_types = 1);
use Drupal\Core\Render\Element;
use Drupal\date_recur\DateRecurCachedHooks;
use Drupal\date_recur\DateRecurViewsHooks;
use Drupal\field\FieldStorageConfigInterface;
/**
* Implements hook_theme().
*/
function date_recur_theme(array $existing, string $type, string $theme, string $path): array {
/** @var \Drupal\date_recur\DateRecurCachedHooks $cachedHooks */
$cachedHooks = \Drupal::classResolver(DateRecurCachedHooks::class);
return $cachedHooks->hookTheme($existing, $type, $theme, $path);
}
/**
* Implements hook_field_info_alter().
*/
function date_recur_field_info_alter(array &$info): void {
/** @var \Drupal\date_recur\DateRecurCachedHooks $cachedHooks */
$cachedHooks = \Drupal::classResolver(DateRecurCachedHooks::class);
$cachedHooks->fieldInfoAlter($info);
}
/**
* Implements hook_field_views_data().
*/
function date_recur_field_views_data(FieldStorageConfigInterface $fieldDefinition): array {
/** @var \Drupal\date_recur\DateRecurViewsHooks $viewsHooks */
$viewsHooks = \Drupal::classResolver(DateRecurViewsHooks::class);
return $viewsHooks->fieldViewsData($fieldDefinition);
}
/**
* Implements hook_views_data().
*/
function date_recur_views_data(): array {
/** @var \Drupal\date_recur\DateRecurViewsHooks $viewsHooks */
$viewsHooks = \Drupal::classResolver(DateRecurViewsHooks::class);
return $viewsHooks->viewsData();
}
/**
* Implements hook_views_data_alter().
*/
function date_recur_views_data_alter(array &$data): void {
/** @var \Drupal\date_recur\DateRecurViewsHooks $viewsHooks */
$viewsHooks = \Drupal::classResolver(DateRecurViewsHooks::class);
$viewsHooks->viewsDataAlter($data);
}
/**
* Template preprocessor for 'date_recur_settings_frequency_table'.
*
* @param array $variables
* An associative array containing:
* - element: An associative array containing a Form API structure to be
* rendered as a table.
*/
function template_preprocess_date_recur_settings_frequency_table(array &$variables): void {
$partTitles = [];
// Transfer elements to 'table' key so they can be iterated on without
// clashing with '#' elements.
$variables['table'] = [];
foreach (Element::children($variables['element']) as $key) {
$variables['table'][$key] = $variables['element'][$key];
$row = &$variables['table'][$key];
foreach (Element::children($row['parts']) as $rowKey) {
$row['parts']['parts'][$rowKey] = $row['parts'][$rowKey];
unset($row['parts'][$rowKey]);
foreach ($row['parts']['parts'] as $part) {
$partTitles[] = $part['#title'];
}
}
unset($variables['element'][$key]);
}
$variables['all_parts'] = array_unique($partTitles);
}