function fullcalendar_field_is_date in FullCalendar 8
Same name and namespace in other branches
- 8.5 fullcalendar.module \fullcalendar_field_is_date()
- 8.2 fullcalendar.module \fullcalendar_field_is_date()
- 8.3 fullcalendar.module \fullcalendar_field_is_date()
- 8.4 fullcalendar.module \fullcalendar_field_is_date()
- 7.2 fullcalendar.module \fullcalendar_field_is_date()
Determines if a given field is a date field.
Parameters
\Drupal\views\Plugin\views\field\EntityField $field: A Views field handler object.
bool $include_gcal: Boolean indicating whether or not to count gcal fields as a date field.
Return value
bool Boolean, TRUE if the field is a date field, FALSE otherwise.
4 calls to fullcalendar_field_is_date()
- FullCalendar::parseFields in src/
Plugin/ views/ style/ FullCalendar.php - Extracts date fields from the view.
- FullCalendar::prepareEvents in src/
Plugin/ views/ style/ FullCalendar.php - Prepare events for calendar.
- FullcalendarLegendBase::build in fullcalendar_legend/
src/ Plugin/ block/ FullcalendarLegendBase.php - Builds and returns the renderable array for this block plugin.
- fullcalendar_views_pre_view in ./
fullcalendar.views_execution.inc - Implements hook_views_pre_view().
File
- ./
fullcalendar.module, line 127 - Provides a views style plugin for FullCalendar
Code
function fullcalendar_field_is_date($field, $include_gcal = FALSE) {
if (!$field instanceof EntityField) {
return FALSE;
}
if ($include_gcal && $field->field == 'gcal') {
return TRUE;
}
$entity_type = $field->definition['entity_type'];
if (empty($entity_type)) {
return FALSE;
}
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */
$field_manager = \Drupal::getContainer()
->get('entity_field.manager');
/** @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] $field_storages */
$field_storages = $field_manager
->getFieldStorageDefinitions($entity_type);
if (isset($field_storages[$field->definition['field_name']])) {
/** @var \Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage */
$field_storage = $field_storages[$field->definition['field_name']];
return in_array($field_storage
->getType(), [
'datetime',
'daterange',
'date_recur',
]);
}
return FALSE;
}