You are here

function _calendar_create_field_arguments in Calendar 8

Create all the granularity arguments for a field.

Parameters

mixed $field_id:

string $group:

Return value

mixed

1 call to _calendar_create_field_arguments()
calendar_views_data_alter in ./calendar.views.inc
Implements hook_views_data_alter().

File

./calendar.views.inc, line 39
Provides views data for the calendar module.

Code

function _calendar_create_field_arguments($field_id, $group = '') {
  $granularity_args = [];

  // All other granularity types are added by core.
  $granularity_types = [
    'year_week' => t('Date in the form of YYYYW'),
  ];
  foreach ($granularity_types as $granularity_type => $granularity_label) {
    $granularity_arg = [
      'title' => t('Calendar @name @granularity', [
        '@name' => $field_id,
        '@granularity' => $granularity_type,
      ]),
      'help' => t('A calendar contextual filter that handles @label.', [
        '@label' => $granularity_label,
      ]),
      'argument' => [
        'field' => $field_id,
        'id' => 'date_' . $granularity_type,
      ],
    ];
    if ($group) {
      $granularity_arg['group'] = $group;
    }
    $granularity_args[$field_id . '_' . $granularity_type] = $granularity_arg;
  }
  return $granularity_args;
}