Ical.php in Views iCal 8
File
src/Plugin/views/style/Ical.php
View source
<?php
namespace Drupal\views_ical\Plugin\views\style;
use Drupal\views\Plugin\views\style\StylePluginBase;
use Drupal\Core\Url;
class Ical extends StylePluginBase {
protected $usesFields = TRUE;
protected $usesGrouping = FALSE;
protected $usesRowPlugin = TRUE;
protected $usesOptions = FALSE;
public function attachTo(array &$build, $display_id, Url $feed_url, $title) {
$url_options = [];
$input = $this->view
->getExposedInput();
if ($input) {
$url_options['query'] = $input;
}
$url_options['absolute'] = TRUE;
$url = $feed_url
->setOptions($url_options)
->toString();
$this->view->feedIcons[] = [];
$build['#attached']['html_head_link'][][] = [
'rel' => 'alternate',
'type' => 'application/calendar',
'href' => $url,
'title' => $title,
];
}
public function render() {
if (empty($this->view->rowPlugin)) {
trigger_error('Drupal\\views_ical\\Plugin\\views\\style\\Ical: Missing row plugin', E_WARNING);
return [];
}
$parent_render = parent::render();
$rows = [];
foreach ($this->view->result as $row_index => $row) {
$this->view->row_index = $row_index;
$rows[] = $this->view->rowPlugin
->render($row);
}
$build = [
'#theme' => $this
->themeFunctions(),
'#view' => $this->view,
'#options' => $this->options,
'#rows' => $rows,
];
unset($this->view->row_index);
return $parent_render;
}
}
Classes
Name |
Description |
Ical |
Style plugin to render an iCal feed. |