function Mapping::defineOptions

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

Overrides StylePluginBase::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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.