You are here

protected function OgDeleteOrphansBase::query in Organic groups 8

Queries the registered group entity for orphaned members to delete.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The group entity that is the basis for the query.

Return value

array An associative array, keyed by entity type, each item an array of entity IDs to delete.

1 call to OgDeleteOrphansBase::query()
OgDeleteOrphansBase::register in src/OgDeleteOrphansBase.php
Registers a soon to be deleted group entity, for processing.

File

src/OgDeleteOrphansBase.php, line 116

Class

OgDeleteOrphansBase
Base implementation for OgDeleteOrphans plugins.

Namespace

Drupal\og

Code

protected function query(EntityInterface $entity) {

  // Register orphaned group content.
  $orphans = $this->membershipManager
    ->getGroupContentIds($entity);

  // Register orphaned user memberships.
  $membership_ids = $this->entityTypeManager
    ->getStorage('og_membership')
    ->getQuery()
    ->condition('entity_type', $entity
    ->getEntityTypeId())
    ->condition('entity_id', $entity
    ->id())
    ->execute();
  if (!empty($membership_ids)) {
    $orphans['og_membership'] = $membership_ids;
  }
  return $orphans;
}