Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /**
|
Chris@0
|
4 * @file
|
Chris@0
|
5 * Preprocessors and theme functions of Aggregator module.
|
Chris@0
|
6 */
|
Chris@0
|
7
|
Chris@0
|
8 use Drupal\Component\Utility\UrlHelper;
|
Chris@0
|
9 use Drupal\Core\Render\Element;
|
Chris@0
|
10
|
Chris@0
|
11 /**
|
Chris@0
|
12 * Prepares variables for aggregator item templates.
|
Chris@0
|
13 *
|
Chris@0
|
14 * Default template: aggregator-item.html.twig.
|
Chris@0
|
15 *
|
Chris@0
|
16 * @param array $variables
|
Chris@0
|
17 * An associative array containing:
|
Chris@0
|
18 * - elements: An array of elements to display in view mode.
|
Chris@0
|
19 */
|
Chris@0
|
20 function template_preprocess_aggregator_item(&$variables) {
|
Chris@0
|
21 $item = $variables['elements']['#aggregator_item'];
|
Chris@0
|
22
|
Chris@0
|
23 // Helpful $content variable for templates.
|
Chris@0
|
24 foreach (Element::children($variables['elements']) as $key) {
|
Chris@0
|
25 $variables['content'][$key] = $variables['elements'][$key];
|
Chris@0
|
26 }
|
Chris@0
|
27
|
Chris@0
|
28 $variables['url'] = UrlHelper::stripDangerousProtocols($item->getLink());
|
Chris@0
|
29 $variables['title'] = $item->label();
|
Chris@0
|
30 }
|
Chris@0
|
31
|
Chris@0
|
32 /**
|
Chris@0
|
33 * Prepares variables for aggregator feed templates.
|
Chris@0
|
34 *
|
Chris@0
|
35 * Default template: aggregator-feed.html.twig.
|
Chris@0
|
36 *
|
Chris@0
|
37 * @param array $variables
|
Chris@0
|
38 * An associative array containing:
|
Chris@0
|
39 * - elements: An array of elements to display in view mode.
|
Chris@0
|
40 */
|
Chris@0
|
41 function template_preprocess_aggregator_feed(&$variables) {
|
Chris@0
|
42 $feed = $variables['elements']['#aggregator_feed'];
|
Chris@0
|
43
|
Chris@0
|
44 // Helpful $content variable for templates.
|
Chris@0
|
45 foreach (Element::children($variables['elements']) as $key) {
|
Chris@0
|
46 $variables['content'][$key] = $variables['elements'][$key];
|
Chris@0
|
47 }
|
Chris@0
|
48 $variables['full'] = $variables['elements']['#view_mode'] == 'full';
|
Chris@0
|
49 $variables['title'] = $feed->label();
|
Chris@0
|
50 }
|