advent_calendar-1.0.0-beta5/advent_calendar.module
advent_calendar.module
<?php
/**
* @file
* Primary module hooks for Advent calendar module.
*/
use Drupal\Core\Template\Attribute;
/**
* Preps variables for views-style-advent-calendar-advent-calendar.html.twig.
*/
function template_preprocess_views_style_advent_calendar_advent_calendar(array &$variables): void {
$view = $variables['view'];
$options = $view->style_plugin->options;
// Fetch wrapper classes from handler options.
if ($options['wrapper_class']) {
$variables['attributes']['class'] = explode(' ', $options['wrapper_class']);
}
$variables['default_row_class'] = $options['default_row_class'];
foreach ($variables['rows'] as $id => $row) {
$variables['rows'][$id] = [
'content' => $row,
'attributes' => new Attribute(),
];
if ($row_class = $view->style_plugin->getRowClass($id)) {
$variables['rows'][$id]['attributes']->addClass($row_class);
}
}
}
/**
* Prepares variables for views-view-fields--advent-calendar.html.twig template.
*/
function template_preprocess_views_view_fields__advent_calendar(array &$variables): void {
$view = $variables['view'];
$options = $view->style_plugin->options;
if ($options['door_closed_image']) {
$variables['door_closed_image'] = $options['door_closed_image'];
}
else {
$variables['door_closed_image'] = "";
}
if ($options['door_open_image']) {
$variables['door_open_image'] = $options['door_open_image'];
}
else {
$variables['door_open_image'] = "";
}
}
/**
* Implements hook_theme().
*/
function advent_calendar_theme($existing, $type, $theme, $path) {
return [
'views_view_fields__advent_calendar' => [
'base hook' => 'views fields',
],
];
}
