vimeo_player-1.0.0-rc1/vimeo_player.module
vimeo_player.module
<?php
use Drupal\Core\Template\Attribute;
/**
* Implements hook_theme().
*/
function vimeo_player_theme() {
return [
'vimeo_player' => [
'render element' => 'vimeo',
]
];
}
function template_preprocess_vimeo_player(&$variables) {
$vimeo = $variables['vimeo'];
$variables['attributes'] = new Attribute($vimeo['#attributes']);
}
/**
* Implements hook_token_info()
*/
function vimeo_player_token_info() {
// Core tokens for nodes.
$vimeo_embed_options['url'] = [
'name' => t("URL"),
'description' => t("URL used to embed the video"),
];
return [
'types' => [
'vimeo_embed_options' => [
'name' => t('Vimeo Emebd Options'),
'description' => t('Embed options used for initializing the vimeo player.'),
'needs-data' => 'vimeo_embed_options',
]
],
'tokens' => ['vimeo_embed_options' => $vimeo_embed_options],
];
}
/**
* Implements hook_tokens()
*/
function vimeo_player_tokens($type, $tokens, array $data, array $options) {
$replacements = [];
if ($type == 'vimeo_embed_options') {
if (!empty($data['vimeo_embed_options'])) {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'url':
$replacements[$original] = $data['vimeo_embed_options']['url'];
break;
}
}
}
}
return $replacements;
}
