You are here

public function GroupContentStorage::loadByContentPluginId in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Storage/GroupContentStorage.php \Drupal\group\Entity\Storage\GroupContentStorage::loadByContentPluginId()

Retrieves all GroupContent entities by their responsible plugin ID.

Parameters

string $plugin_id: The ID of the content enabler plugin.

Return value

\Drupal\group\Entity\GroupContentInterface[] A list of GroupContent entities indexed by their IDs.

Overrides GroupContentStorageInterface::loadByContentPluginId

File

src/Entity/Storage/GroupContentStorage.php, line 130

Class

GroupContentStorage
Defines the storage handler class for group content entities.

Namespace

Drupal\group\Entity\Storage

Code

public function loadByContentPluginId($plugin_id) {

  // If no responsible group content types were found, we return nothing.

  /** @var \Drupal\group\Entity\Storage\GroupContentTypeStorageInterface $storage */
  $storage = $this->entityTypeManager
    ->getStorage('group_content_type');
  $group_content_types = $storage
    ->loadByContentPluginId($plugin_id);
  if (empty($group_content_types)) {
    return [];
  }
  return $this
    ->loadByProperties([
    'type' => array_keys($group_content_types),
  ]);
}