You are here

public function Boolean::init in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/Boolean.php \Drupal\views\Plugin\views\field\Boolean::init()

Initialize the plugin.

Parameters

\Drupal\views\ViewExecutable $view: The view object.

\Drupal\views\Plugin\views\display\DisplayPluginBase $display: The display handler.

array $options: The options configured for this plugin.

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