Same name and namespace in other branches
  1. 8.9.x core/modules/views/src/Plugin/views/style/Mapping.php \Drupal\views\Plugin\views\style\Mapping::defineOptions()
  2. 9 core/modules/views/src/Plugin/views/style/Mapping.php \Drupal\views\Plugin\views\style\Mapping::defineOptions()

File

core/modules/views/src/Plugin/views/style/Mapping.php, line 47

Class

Mapping
Allows fields to be mapped to specific use cases.

Namespace

Drupal\views\Plugin\views\style

Code

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

  // Parse the mapping and add a default for each.
  foreach ($this
    ->defineMapping() as $key => $value) {
    $default = !empty($value['#multiple']) ? [] : '';
    $options['mapping']['contains'][$key] = [
      'default' => $value['#default_value'] ?? $default,
    ];
    if (!empty($value['#toggle'])) {
      $options['mapping']['contains']["toggle_{$key}"] = [
        'default' => FALSE,
      ];
    }
  }
  return $options;
}