You are here

function social_path_manager_batch_alter in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  2. 8.5 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  3. 8.6 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  4. 8.7 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  5. 8.8 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  6. 10.0.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  7. 10.1.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()
  8. 10.2.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_batch_alter()

Implements hook_batch_alter().

File

modules/custom/social_path_manager/social_path_manager.module, line 78
The Social Path Manager module.

Code

function social_path_manager_batch_alter(&$batch) {
  if (!isset($batch['source_url'])) {
    return;
  }

  /** @var \Drupal\Core\Url $url */
  $url =& $batch['source_url'];

  // Bulk generate aliases include group tabs.
  if ($url
    ->getRouteName() === 'pathauto.bulk.update.form') {
    $options = $batch['form_state']
      ->getValue('update');
    $action = $batch['form_state']
      ->getValue('action');

    // Check if the operation contains a group update.
    if ($options['canonical_entities:group'] === 'canonical_entities:group') {

      // Set additional batch to create group aliases for group tabs.
      $batch['operations'][] = [
        '_social_path_manager_update_group_tab_aliases',
        [
          'canonical_entities:group',
          $action,
        ],
      ];
      batch_set($batch);
    }
  }
}