You are here

function _social_group_get_action_id in Open Social 8.9

Same name and namespace in other branches
  1. 8.5 modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  2. 8.6 modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  3. 8.7 modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  4. 8.8 modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  5. 10.3.x modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  6. 10.0.x modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  7. 10.1.x modules/social_features/social_group/social_group.module \_social_group_get_action_id()
  8. 10.2.x modules/social_features/social_group/social_group.module \_social_group_get_action_id()

Function to get the action id of a batch.

Parameters

array $batch: The batch array.

Return value

string Returns the batch action id.

1 call to _social_group_get_action_id()
social_group_batch_alter in modules/social_features/social_group/social_group.module
Implements hook_batch_alter().

File

modules/social_features/social_group/social_group.module, line 2134
The Social group module.

Code

function _social_group_get_action_id(array &$batch) {

  /** @var \Drupal\Core\Form\FormStateInterface $form_state */
  $form_state =& $batch['form_state'];
  $action_id = '';
  if ($form_state instanceof FormStateInterface) {
    $data = $form_state
      ->get('views_bulk_operations');
    $action_id = $data['action_id'];
  }
  else {
    foreach ($batch['sets'][0]['operations'] as $operations) {
      if (empty($operations) || !is_array($operations)) {
        break;
      }
      foreach ($operations as $operation) {
        if (empty($operation) || !is_array($operation)) {
          break;
        }
        foreach ($operation as $items) {
          if (empty($items) || !is_array($items)) {
            break;
          }
          if (!empty($items['action_id'])) {
            $action_id = $items['action_id'];
            break;
          }
        }
      }
    }
  }
  return $action_id;
}