You are here

public static function DeleteGroup::deleteGroupAndContent in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  2. 8.2 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  3. 8.3 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  4. 8.4 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  5. 8.5 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  6. 8.6 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  7. 8.7 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  8. 8.8 modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  9. 10.3.x modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  10. 10.0.x modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  11. 10.1.x modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()
  12. 10.2.x modules/social_features/social_group/src/Controller/DeleteGroup.php \Drupal\social_group\Controller\DeleteGroup::deleteGroupAndContent()

Get the group and all of its content that needs to be deleted.

File

modules/social_features/social_group/src/Controller/DeleteGroup.php, line 20

Class

DeleteGroup
Class DeleteGroup.

Namespace

Drupal\social_group\Controller

Code

public static function deleteGroupAndContent($nids, $posts, &$context) {
  $results = [];

  // Load each node and delete it.
  foreach ($nids as $nid) {
    $node = Node::load($nid);
    $message = t('Delete @type "@title"', [
      '@type' => $node
        ->getType(),
      '@title' => $node
        ->getTitle(),
    ]);
    $results[] = $node
      ->delete();
  }

  // Load each post and delete it.
  foreach ($posts as $post_id) {
    $post = Post::load($post_id);
    $message = t("Deleting @type\\'s", [
      '@type' => $post
        ->bundle(),
    ]);
    $results[] = $post
      ->delete();
  }
  $context['message'] = $message;
  $context['results'] = $results;
}