You are here

date_recur_modular.module in Recurring Date Field Modular Widgets 8

Same filename and directory in other branches
  1. 3.x date_recur_modular.module
  2. 2.x date_recur_modular.module

File

date_recur_modular.module
View source
<?php

/**
 * @file
 * Hooks for Date Recur Modular Widget Framework.
 */
declare (strict_types=1);

/**
 * Implements hook_theme().
 */
function date_recur_modular_theme(array $existing, string $type, string $theme, string $path) : array {
  return [
    'date_recur_modular_alpha_widget' => [
      'render element' => 'widget',
    ],
    'date_recur_modular_oscar_widget' => [
      'render element' => 'widget',
    ],
    'date_recur_modular_sierra_widget' => [
      'render element' => 'widget',
    ],
    'date_recur_modular_sierra_widget_modal_form' => [
      'render element' => 'form',
    ],
    'date_recur_modular_sierra_widget_modal_occurrences_form' => [
      'render element' => 'form',
    ],
    'date_recur_modular_sierra_widget_modal_form_ends' => [
      'render element' => 'form',
    ],
  ];
}

/**
 * Implements hook_preprocess_HOOK().
 *
 * HOOK: 'date_recur_modular_widget'.
 */
function template_preprocess_date_recur_modular_alpha_widget(array &$variables) : void {
  $variables['attributes']['class'][] = 'date-recur-modular-alpha-widget';
  $variables['#attached']['library'][] = 'date_recur_modular/date_recur_modular_alpha_widget';
}

/**
 * Implements hook_preprocess_HOOK().
 *
 * HOOK: 'date_recur_modular_oscar_widget'.
 */
function template_preprocess_date_recur_modular_oscar_widget(array &$variables) : void {
  $variables['attributes']['class'][] = 'date-recur-modular-oscar-widget';
  $variables['#attached']['library'][] = 'date_recur_modular/date_recur_modular_oscar_widget';
}

/**
 * Implements hook_preprocess_HOOK().
 *
 * HOOK: 'date_recur_modular_sierra_widget'.
 */
function template_preprocess_date_recur_modular_sierra_widget(array &$variables) : void {
  $variables['attributes']['class'][] = 'date-recur-modular-sierra-widget';
  $variables['#attached']['library'][] = 'date_recur_modular/date_recur_modular_sierra_widget';
}

/**
 * Implements hook_preprocess_HOOK().
 *
 * HOOK: 'date_recur_modular_sierra_widget_modal_form'.
 */
function template_preprocess_date_recur_modular_sierra_widget_modal_form(array &$variables) : void {
  $variables['attributes']['class'][] = 'date-recur-modular-sierra-modal';

  // Wait until \Drupal\Core\Render\Element\Checkboxes::processCheckboxes is
  // run so attributes are not replicated to children.
  $variables['form']['weekdays']['#attributes']['class'][] = 'container-inline';
  $variables['form']['weekdays']['#attributes']['class'][] = 'weekdays';
}

/**
 * Implements hook_preprocess_HOOK().
 *
 * HOOK: 'date_recur_modular_sierra_widget_modal_occurrences_form'.
 */
function template_preprocess_date_recur_modular_sierra_widget_modal_occurrences_form(array &$variables) : void {
  $variables['attributes']['class'][] = 'date-recur-modular-sierra-occurences-modal';
  $variables['form']['occurrences']['show_more']['#attributes']['class'][] = 'show-more-wrapper';
}