You are here

trumba.module in Trumba 8

Same filename and directory in other branches
  1. 7 trumba.module
  2. 2.x trumba.module

Contains trumba.module..

File

trumba.module
View source
<?php

/**
 * @file
 * Contains trumba.module..
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Cache\CacheableMetadata;

/**
 * Implements hook_help().
 */
function trumba_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the trumba module.
    case 'help.page.trumba':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides a way to place trumba calendar elements (spuds) on a page.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Create Javascript settings for a Trumba Spud.
 *
 * @param string $spud_id
 *    The identifier of the spud.
 * @param array $params
 *    The array of configuration parameters.
 */
function _trumba_spud_embed($spud_id, $params, $cache_tag_id) {
  $build = [];
  $build['#theme'] = 'trumba_calendar';
  $build['#spud_id'] = $spud_id;
  $build['#attached']['library'][] = 'trumba/trumba';
  $build['#attached']['library'][] = 'trumba/trumba.embed';
  $build['#attached']['drupalSettings']['trumba'][$spud_id] = $params;
  $cacheableMetadata = new CacheableMetadata();
  $cacheableMetadata
    ->setCacheTags([
    'trumba:' . $cache_tag_id,
  ]);
  $cacheableMetadata
    ->applyTo($build);
  return $build;
}

/**
 * Implements hook_theme().
 */
function trumba_theme() {
  $return = array();
  $return['trumba_calendar'] = [
    'variables' => [
      'spud_id' => '',
    ],
  ];
  return $return;
}

Functions

Namesort descending Description
trumba_help Implements hook_help().
trumba_theme Implements hook_theme().
_trumba_spud_embed Create Javascript settings for a Trumba Spud.