protected function Field::defineOptions

Information about options for all kinds of purposes will be held here. @code 'option_name' => array(

  • 'default' => default value,
  • 'translatable' => (optional) TRUE/FALSE (wrap in t() on export if true),
  • 'contains' => (optional) array of items this contains, with its own defaults, etc. If contains is set, the default will be ignored and assumed to be array().
  • 'bool' => (optional) TRUE/FALSE Is the value a boolean value. This will change the export format to TRUE/FALSE instead of 1/0.

),

Return value

array Returns the options of this handler/plugin.

Overrides FieldPluginBase::defineOptions

File

drupal/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php, line 255
Definition of Drupal\field\Plugin\views\field\Field.

Class

Field
A field that displays fieldapi fields.

Namespace

Drupal\field\Plugin\views\field

Code

protected function defineOptions() {
  $options = parent::defineOptions();

  // defineOptions runs before init/construct, so no $this->field_info
  $field = field_info_field($this->definition['field_name']);
  $field_type = field_info_field_types($field['type']);
  $column_names = array_keys($field['columns']);
  $default_column = '';

  // Try to determine a sensible default.
  if (count($column_names) == 1) {
    $default_column = $column_names[0];
  }
  elseif (in_array('value', $column_names)) {
    $default_column = 'value';
  }

  // If the field has a "value" column, we probably need that one.
  $options['click_sort_column'] = array(
    'default' => $default_column,
  );
  $options['type'] = array(
    'default' => $field_type['default_formatter'],
  );
  $options['settings'] = array(
    'default' => array(),
  );
  $options['group_column'] = array(
    'default' => $default_column,
  );
  $options['group_columns'] = array(
    'default' => array(),
  );

  // Options used for multiple value fields.
  $options['group_rows'] = array(
    'default' => TRUE,
    'bool' => TRUE,
  );

  // If we know the exact number of allowed values, then that can be
  // the default. Otherwise, default to 'all'.
  $options['delta_limit'] = array(
    'default' => $field['cardinality'] > 1 ? $field['cardinality'] : 'all',
  );
  $options['delta_offset'] = array(
    'default' => 0,
  );
  $options['delta_reversed'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );
  $options['delta_first_last'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );
  $options['multi_type'] = array(
    'default' => 'separator',
  );
  $options['separator'] = array(
    'default' => ', ',
  );
  $options['field_api_classes'] = array(
    'default' => FALSE,
    'bool' => TRUE,
  );
  return $options;
}