You are here

public static function SetGroupsForNodeService::removeGroupContent in Open Social 8.8

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

Deletes a group content.

Parameters

\Drupal\node\NodeInterface $node: Object of a node.

\Drupal\group\Entity\Group $group: Object of a group.

1 call to SetGroupsForNodeService::removeGroupContent()
SetGroupsForNodeService::setGroupsForNode in modules/social_features/social_group/src/SetGroupsForNodeService.php
Save groups for a given node.

File

modules/social_features/social_group/src/SetGroupsForNodeService.php, line 179

Class

SetGroupsForNodeService
Class SetGroupsForNodeService.

Namespace

Drupal\social_group

Code

public static function removeGroupContent(NodeInterface $node, Group $group) {

  // Try to load group content from entity.
  if ($group_contents = GroupContent::loadByEntity($node)) {

    /* @var @param \Drupal\group\Entity\GroupContent $group_content */
    foreach ($group_contents as $group_content) {
      if ($group
        ->id() === $group_content
        ->getGroup()
        ->id()) {
        $group_content
          ->delete();
      }
    }
  }
}