You are here

function _trumba_spud_embed in Trumba 2.x

Same name and namespace in other branches
  1. 8 trumba.module \_trumba_spud_embed()
  2. 7 trumba.module \_trumba_spud_embed()

Create Javascript settings for a Trumba Spud.

Parameters

string $spud_id: The identifier of the spud.

array $params: The array of configuration parameters.

3 calls to _trumba_spud_embed()
TrumbaMainCalendarSpudBlock::build in src/Plugin/Block/TrumbaMainCalendarSpudBlock.php
Builds and returns the renderable array for this block plugin.
TrumbaOpenSpudBlock::build in src/Plugin/Block/TrumbaOpenSpudBlock.php
Builds and returns the renderable array for this block plugin.
TrumbaPromoControlSpudBlock::build in src/Plugin/Block/TrumbaPromoControlSpudBlock.php
Builds and returns the renderable array for this block plugin.

File

./trumba.module, line 35
Contains trumba.module..

Code

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;
}