-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddtocalendar.module
54 lines (47 loc) · 1.51 KB
/
addtocalendar.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
* Contains module code.
*/
use Drupal\Core\Routing\RouteMatchInterface;
require 'includes/addtocalendar.form.inc';
require 'includes/addtocalendar.build.inc';
/**
* Implements hook_help().
*/
function addtocalendar_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.addtocalendar':
$output = file_get_contents(drupal_get_path('module', 'addtocalendar') . '/README.md');
return $output;
}
}
/**
* Implements hook_field_formatter_third_party_settings_form().
*/
function addtocalendar_field_formatter_third_party_settings_form($plugin, $field_definition, $view_mode, $form, $form_state) {
$element = [];
if (in_array('datetime', $plugin->getPluginDefinition()['field_types'])) {
$settings = $plugin->getThirdPartySettings('addtocalendar');
$element = _addtocalendar_build_form($settings, $field_definition);
}
return $element;
}
/**
* Implements hook_field_formatter_settings_summary_alter().
*/
function addtocalendar_field_formatter_settings_summary_alter(&$summary, $context) {
if (in_array('datetime', $context['formatter']->getPluginDefinition()['field_types'])) {
if ($context['formatter']->getThirdPartySetting('addtocalendar', 'addtocalendar_show')) {
$summary[] = t('Add to calendar enabled');
}
}
}
/**
* Implements hook_preprocess_field().
*/
function addtocalendar_preprocess_field(&$variables) {
if ($variables['field_type'] == 'datetime') {
_addtocalendar_preprocess_field($variables);
}
}