You are here

protected function Mapping::defineOptions in Drupal 9

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

Information about options for all kinds of purposes will be held here.


'option_name' => array(
 - 'default' => default value,
 - '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().
 ),

Return value

array Returns the options of this handler/plugin.

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' => isset($value['#default_value']) ? $value['#default_value'] : $default,
    ];
    if (!empty($value['#toggle'])) {
      $options['mapping']['contains']["toggle_{$key}"] = [
        'default' => FALSE,
      ];
    }
  }
  return $options;
}