-
Notifications
You must be signed in to change notification settings - Fork 13
/
membership.page.inc
62 lines (57 loc) · 1.67 KB
/
membership.page.inc
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
<?php
/**
* @file
* Contains membership.page.inc.
*
* Page callback for Membership entities.
*/
use Drupal\Core\Render\Element;
use Drupal\Core\Link;
use Drupal\Core\Url;
/**
* Prepares variables for Membership templates.
*
* Default template: membership.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_membership(array &$variables) {
// Fetch Membership Entity Object.
$membership = $variables['elements']['#membership'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
/**
* Prepares variables for a custom entity type creation list templates.
*
* Default template: membership-content-add-list.html.twig.
*
* @param array $variables
* An associative array containing:
* - content: An array of membership-types.
*
* @see block_content_add_page()
*/
function template_preprocess_membership_content_add_list(&$variables) {
$variables['types'] = array();
$query = \Drupal::request()->query->all();
foreach ($variables['content'] as $type) {
$variables['types'][$type->id()] = array(
'link' => Link::fromTextAndUrl($type->label(), new Url('entity.membership.add_form', array(
'membership_type' => $type->id()
), array('query' => $query))),
'description' => array(
'#markup' => $type->label(),
),
'title' => $type->label(),
'localized_options' => array(
'query' => $query,
),
);
}
}