addfolder
This commit is contained in:
@@ -0,0 +1,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 (count(array_intersect(['datetime', 'daterange'], $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 (count(array_intersect(['datetime', 'daterange'], $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' || $variables['field_type'] == 'daterange') {
|
||||
_addtocalendar_preprocess_field($variables);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user