You are here

function fullcalendar_field_is_date in FullCalendar 8.5

Same name and namespace in other branches
  1. 8 fullcalendar.module \fullcalendar_field_is_date()
  2. 8.2 fullcalendar.module \fullcalendar_field_is_date()
  3. 8.3 fullcalendar.module \fullcalendar_field_is_date()
  4. 8.4 fullcalendar.module \fullcalendar_field_is_date()
  5. 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.

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 modules/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 108
Provides a views style plugin for FullCalendar

Code

function fullcalendar_field_is_date(EntityField $field) {
  if (!$field instanceof EntityField) {
    return FALSE;
  }
  $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;
}