You are here

protected function ViewsBulkOperationsBulkForm::getBulkOptions in Views Bulk Operations (VBO) 4.0.x

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. 8.2 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 845

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->options['selected_actions'] as $key => $selected_action_data) {
      if (!isset($this->actions[$selected_action_data['action_id']])) {
        continue;
      }
      $definition = $this->actions[$selected_action_data['action_id']];

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

      // Check custom access, if defined.
      if (!empty($definition['requirements']['_custom_access']) && !$definition['class']::customAccess($this->currentUser, $this->view)) {
        continue;
      }

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