function Boolean::init

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::init()
  2. 10 core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::init()
  3. 11.x core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::init()

Overrides FieldPluginBase::init

File

core/modules/views/src/Plugin/views/field/Boolean.php, line 48

Class

Boolean
A handler to provide proper displays for booleans.

Namespace

Drupal\views\Plugin\views\field

Code

public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $default_formats = [
        'yes-no' => [
            t('Yes'),
            $this->t('No'),
        ],
        'true-false' => [
            t('True'),
            $this->t('False'),
        ],
        'on-off' => [
            t('On'),
            $this->t('Off'),
        ],
        'enabled-disabled' => [
            t('Enabled'),
            $this->t('Disabled'),
        ],
        'boolean' => [
            1,
            0,
        ],
        'unicode-yes-no' => [
            '✔',
            '✖',
        ],
    ];
    $output_formats = isset($this->definition['output formats']) ? $this->definition['output formats'] : [];
    $custom_format = [
        'custom' => [
            t('Custom'),
        ],
    ];
    $this->formats = array_merge($default_formats, $output_formats, $custom_format);
}

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