2014-02-13 10:17:50 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Preprocessors and theme functions of Aggregator module.
|
|
|
|
*/
|
|
|
|
|
2015-08-31 07:51:38 +00:00
|
|
|
use Drupal\Component\Utility\UrlHelper;
|
2014-03-31 17:37:55 +00:00
|
|
|
use Drupal\Core\Render\Element;
|
2014-02-13 10:17:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepares variables for aggregator item templates.
|
|
|
|
*
|
|
|
|
* Default template: aggregator-item.html.twig.
|
|
|
|
*
|
|
|
|
* @param array $variables
|
|
|
|
* An associative array containing:
|
2014-09-22 11:36:15 +00:00
|
|
|
* - elements: An array of elements to display in view mode.
|
2014-02-13 10:17:50 +00:00
|
|
|
*/
|
|
|
|
function template_preprocess_aggregator_item(&$variables) {
|
2014-09-22 11:36:15 +00:00
|
|
|
$item = $variables['elements']['#aggregator_item'];
|
2014-02-13 10:17:50 +00:00
|
|
|
|
2014-09-22 11:36:15 +00:00
|
|
|
// Helpful $content variable for templates.
|
|
|
|
foreach (Element::children($variables['elements']) as $key) {
|
|
|
|
$variables['content'][$key] = $variables['elements'][$key];
|
2014-02-13 10:17:50 +00:00
|
|
|
}
|
|
|
|
|
2015-08-31 07:51:38 +00:00
|
|
|
$variables['url'] = UrlHelper::stripDangerousProtocols($item->getLink());
|
2015-08-27 14:42:23 +00:00
|
|
|
$variables['title'] = $item->label();
|
2014-02-13 10:17:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-22 11:36:15 +00:00
|
|
|
* Prepares variables for aggregator feed templates.
|
2014-02-13 10:17:50 +00:00
|
|
|
*
|
2014-09-22 11:36:15 +00:00
|
|
|
* Default template: aggregator-feed.html.twig.
|
2014-02-13 10:17:50 +00:00
|
|
|
*
|
|
|
|
* @param array $variables
|
|
|
|
* An associative array containing:
|
2014-09-22 11:36:15 +00:00
|
|
|
* - elements: An array of elements to display in view mode.
|
2014-02-13 10:17:50 +00:00
|
|
|
*/
|
2014-09-22 11:36:15 +00:00
|
|
|
function template_preprocess_aggregator_feed(&$variables) {
|
|
|
|
$feed = $variables['elements']['#aggregator_feed'];
|
2014-02-13 10:17:50 +00:00
|
|
|
|
2014-09-22 11:36:15 +00:00
|
|
|
// Helpful $content variable for templates.
|
|
|
|
foreach (Element::children($variables['elements']) as $key) {
|
|
|
|
$variables['content'][$key] = $variables['elements'][$key];
|
2014-02-13 10:17:50 +00:00
|
|
|
}
|
2014-09-22 11:36:15 +00:00
|
|
|
$variables['full'] = $variables['elements']['#view_mode'] == 'full';
|
2015-08-27 14:42:23 +00:00
|
|
|
$variables['title'] = $feed->label();
|
2014-02-13 10:17:50 +00:00
|
|
|
}
|