public function GroupContentStorage::loadByGroup in Group 2.0.x
Same name and namespace in other branches
- 8 src/Entity/Storage/GroupContentStorage.php \Drupal\group\Entity\Storage\GroupContentStorage::loadByGroup()
Retrieves all GroupContent entities for a group.
Parameters
\Drupal\group\Entity\GroupInterface $group: The group entity to load the group content entities for.
string $plugin_id: (optional) A group relation plugin ID to filter on.
array $filters: (optional) An associative array of extra filters where the keys are property or field names and the values are the value to filter on.
Return value
\Drupal\group\Entity\GroupContentInterface[] A list of GroupContent entities matching the criteria.
Overrides GroupContentStorageInterface::loadByGroup
File
- src/
Entity/ Storage/ GroupContentStorage.php, line 67
Class
- GroupContentStorage
- Defines the storage handler class for group content entities.
Namespace
Drupal\group\Entity\StorageCode
public function loadByGroup(GroupInterface $group, $plugin_id = NULL, $filters = []) {
// An unsaved group cannot have any content.
if ($group
->id() === NULL) {
throw new EntityStorageException("Cannot load GroupContent entities for an unsaved group.");
}
$properties = [
'gid' => $group
->id(),
] + $filters;
// If a plugin ID was provided, set the group content type ID for it.
if (isset($plugin_id)) {
$plugin = $group
->getGroupType()
->getContentPlugin($plugin_id);
$properties['type'] = $plugin
->getContentTypeConfigId();
}
return $this
->loadByProperties($properties);
}