You are here

protected function EntityReferenceActionsHandler::getBulkOptions in Entity reference actions 1.x

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.

See also

\Drupal\views\Plugin\views\field\BulkForm

2 calls to EntityReferenceActionsHandler::getBulkOptions()
EntityReferenceActionsHandler::buildSettingsForm in src/EntityReferenceActionsHandler.php
Build the settings form.
EntityReferenceActionsHandler::formAlter in src/EntityReferenceActionsHandler.php
Build the form elements.

File

src/EntityReferenceActionsHandler.php, line 450

Class

EntityReferenceActionsHandler
Provides the form functions to call actions on referenced entities.

Namespace

Drupal\entity_reference_actions

Code

protected function getBulkOptions($filtered = TRUE) {
  $options = [];

  // Filter the action list.

  /** @var \Drupal\system\ActionConfigEntityInterface $action */
  foreach ($this->actions as $id => $action) {
    if ($filtered) {
      $in_selected = in_array($id, array_filter($this->settings['options']['selected_actions']));

      // If the field is configured to include only the selected actions,
      // skip actions that were not selected.
      if ($this->settings['options']['include_exclude'] == 'include' && !$in_selected) {
        continue;
      }
      elseif ($this->settings['options']['include_exclude'] == 'exclude' && $in_selected) {
        continue;
      }
    }
    $options[$id] = $this
      ->getActionLabel($action);
  }
  return $options;
}