You are here

public function GroupTypeManager::getGroupBundleIdsByGroupContentBundle in Organic groups 8

Returns all group bundles that are referenced by the given group content.

Parameters

string $group_content_entity_type_id: The entity type ID of the group content type for which to return associated group bundle IDs.

string $group_content_bundle_id: The bundle ID of the group content type for which to return associated group bundle IDs.

Return value

string[][] An array of group bundle IDs, keyed by group entity type ID.

Overrides GroupTypeManagerInterface::getGroupBundleIdsByGroupContentBundle

1 call to GroupTypeManager::getGroupBundleIdsByGroupContentBundle()
GroupTypeManager::populateGroupRelationMap in src/GroupTypeManager.php
Populates the map of relations between group types and group content types.

File

src/GroupTypeManager.php, line 229

Class

GroupTypeManager
A manager to keep track of which entity type/bundles are OG group enabled.

Namespace

Drupal\og

Code

public function getGroupBundleIdsByGroupContentBundle($group_content_entity_type_id, $group_content_bundle_id) {
  $bundles = [];
  foreach ($this->groupAudienceHelper
    ->getAllGroupAudienceFields($group_content_entity_type_id, $group_content_bundle_id) as $field) {
    $group_entity_type_id = $field
      ->getSetting('target_type');
    $handler_settings = $field
      ->getSetting('handler_settings');
    $group_bundle_ids = !empty($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : [];

    // If the group bundles are empty, it means that all bundles are
    // referenced.
    if (empty($group_bundle_ids)) {
      $group_bundle_ids = $this
        ->getGroupMap()[$group_entity_type_id];
    }
    foreach ($group_bundle_ids as $group_bundle_id) {
      $bundles[$group_entity_type_id][$group_bundle_id] = $group_bundle_id;
    }
  }
  return $bundles;
}