function BulkForm::getBulkOptions

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

Returns the available operations for this form.

Parameters

bool $filtered: (optional) Whether to filter actions to selected actions.

Return value

array An associative array of operations, suitable for a select element.

2 calls to BulkForm::getBulkOptions()
BulkForm::buildOptionsForm in core/modules/views/src/Plugin/views/field/BulkForm.php
Default options form that provides the label widget that all fields should have.
BulkForm::viewsForm in core/modules/views/src/Plugin/views/field/BulkForm.php
Form constructor for the bulk form.

File

core/modules/views/src/Plugin/views/field/BulkForm.php, line 362

Class

BulkForm
Defines a actions-based bulk operation form element.

Namespace

Drupal\views\Plugin\views\field

Code

protected function getBulkOptions($filtered = TRUE) {
    $options = [];
    // Filter the action list.
    foreach ($this->actions as $id => $action) {
        if ($filtered) {
            $in_selected = in_array($id, $this->options['selected_actions']);
            // If the field is configured to include only the selected actions,
            // skip actions that were not selected.
            if ($this->options['include_exclude'] == 'include' && !$in_selected) {
                continue;
            }
            elseif ($this->options['include_exclude'] == 'exclude' && $in_selected) {
                continue;
            }
        }
        $options[$id] = $action->label();
    }
    return $options;
}

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