You are here

protected function MappingTest::defineMapping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php \Drupal\views_test_data\Plugin\views\style\MappingTest::defineMapping()

Builds the list of field mappings.

Return value

array An associative array, keyed by the field name, containing the following key-value pairs:

  • #title: The human-readable label for this field.
  • #default_value: The default value for this field. If not provided, an empty string will be used.
  • #description: A description of this field.
  • #required: Whether this field is required.
  • #filter: (optional) A method on the plugin to filter field options.
  • #toggle: (optional) If this select should be toggled by a checkbox.

Overrides Mapping::defineMapping

File

core/modules/views/tests/modules/views_test_data/src/Plugin/views/style/MappingTest.php, line 31
Contains \Drupal\views_test_data\Plugin\views\style\MappingTest.

Class

MappingTest
Provides a test plugin for the mapping style.

Namespace

Drupal\views_test_data\Plugin\views\style

Code

protected function defineMapping() {
  return array(
    'title_field' => array(
      '#title' => $this
        ->t('Title field'),
      '#description' => $this
        ->t('Choose the field with the custom title.'),
      '#toggle' => TRUE,
      '#required' => TRUE,
    ),
    'name_field' => array(
      '#title' => $this
        ->t('Name field'),
      '#description' => $this
        ->t('Choose the field with the custom name.'),
    ),
    'numeric_field' => array(
      '#title' => $this
        ->t('Numeric field'),
      '#description' => $this
        ->t('Select one or more numeric fields.'),
      '#multiple' => TRUE,
      '#toggle' => TRUE,
      '#filter' => 'filterNumericFields',
      '#required' => TRUE,
    ),
  );
}