Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Mapping.php

function 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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal