function views_rss_get in Views RSS 8.2
Same name and namespace in other branches
- 8.3 views_rss.module \views_rss_get()
- 6.2 views_rss.module \views_rss_get()
- 7.2 views_rss.module \views_rss_get()
Returns an array of item elements defined by other modules with hook_views_rss_item_elements() and optionally altered with hook_views_rss_item_elements_alter() implementations.
10 calls to views_rss_get()
- RssFields::buildOptionsForm in src/
Plugin/ views/ style/ RssFields.php - Provide a form to edit options for this plugin.
- RssFields::buildOptionsForm in src/
Plugin/ views/ row/ RssFields.php - Function buildOptionsForm.
- RssFields::defineOptions in src/
Plugin/ views/ style/ RssFields.php - Information about options for all kinds of purposes will be held here.
- RssFields::defineOptions in src/
Plugin/ views/ row/ RssFields.php - Function defineOptions.
- RssFields::getChannelElements in src/
Plugin/ views/ style/ RssFields.php - Return an array of additional XHTML elements to add to the channel.
File
- ./
views_rss.module, line 15 - Module providing fields-based views style plugin for RSS feed generation.
Code
function views_rss_get($key, $rebuild = FALSE) {
static $data = array();
if (!isset($data[$key]) || empty($data[$key]) || $rebuild === TRUE) {
$cid = 'views_rss:' . $key;
$cache = \Drupal::cache('data')
->get($cid);
if (isset($cache->data) && $rebuild === FALSE) {
$data[$key] = $cache->data;
}
else {
// Fetch item elements provided by other modules. We need to manually call
// each module so that we can know which module a given item came from.
$data[$key] = array();
$hook_name = 'views_rss_' . $key;
$modules = \Drupal::moduleHandler()
->getImplementations($hook_name);
foreach ($modules as $module) {
$module_data = \Drupal::moduleHandler()
->invoke($module, $hook_name);
if (isset($module_data) && is_array($module_data)) {
$data[$key][$module] = $module_data;
}
}
// Add namespaces not defined by any hook_views_rss_namespaces(),
// but used in any of defined <channel> or <item> elements.
// Let's also add "xmlns" prefix by default to such namespaces.
$function = '_views_rss_process_' . $key;
if (function_exists($function)) {
$data[$key] = $function($data[$key]);
}
// Allow other modules to alter obtained item elements.
\Drupal::moduleHandler()
->alter($hook_name, $data[$key]);
// Store it infinitely in cache (rebuild only on cache clear).
\Drupal::cache('data')
->set($cid, $data[$key]);
}
}
return $data[$key];
}