protected function BulkForm::getBulkOptions

Implements \Drupal\system\Plugin\views\field\BulkFormBase::getBulkOptions().

Parameters

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

Overrides BulkFormBase::getBulkOptions

1 call to BulkForm::getBulkOptions()
BulkForm::buildOptionsForm in drupal/core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php
Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::buildOptionsForm().

File

drupal/core/modules/action/lib/Drupal/action/Plugin/views/field/BulkForm.php, line 72
Contains \Drupal\action\Plugin\views\field\BulkForm.

Class

BulkForm
Defines a actions-based bulk operation form element.

Namespace

Drupal\action\Plugin\views\field

Code

protected function getBulkOptions($filtered = TRUE) {

  // Get all available actions.
  $entity_type = $this
    ->getEntityType();
  $options = array();

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

    // Only allow actions that are valid for this entity type.
    if ($action
      ->getType() == $entity_type) {
      $options[$id] = $action
        ->label();
    }
  }
  return $options;
}