You are here

protected function ViewsBulkOperationsBulkForm::getBulkOptions in Views Bulk Operations (VBO) 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::getBulkOptions()
  2. 8 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::getBulkOptions()
  3. 4.0.x src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::getBulkOptions()

Returns the available operations for this form.

Return value

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

2 calls to ViewsBulkOperationsBulkForm::getBulkOptions()
ViewsBulkOperationsBulkForm::preRender in src/Plugin/views/field/ViewsBulkOperationsBulkForm.php
Runs before any fields are rendered.
ViewsBulkOperationsBulkForm::viewsForm in src/Plugin/views/field/ViewsBulkOperationsBulkForm.php
Form constructor for the bulk form.

File

src/Plugin/views/field/ViewsBulkOperationsBulkForm.php, line 723

Class

ViewsBulkOperationsBulkForm
Defines the Views Bulk Operations field plugin.

Namespace

Drupal\views_bulk_operations\Plugin\views\field

Code

protected function getBulkOptions() {
  if (!isset($this->bulkOptions)) {
    $this->bulkOptions = [];
    foreach ($this->actions as $id => $definition) {

      // Filter out actions that weren't selected.
      if (!in_array($id, $this->options['selected_actions'], TRUE)) {
        continue;
      }

      // Check access permission, if defined.
      if (!empty($definition['requirements']['_permission']) && !$this->currentUser
        ->hasPermission($definition['requirements']['_permission'])) {
        continue;
      }

      // Override label if applicable.
      if (!empty($this->options['preconfiguration'][$id]['label_override'])) {
        $this->bulkOptions[$id] = $this->options['preconfiguration'][$id]['label_override'];
      }
      else {
        $this->bulkOptions[$id] = $definition['label'];
      }
    }
  }
  return $this->bulkOptions;
}