public function WebformGroupManager::getCurrentGroupContent in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_group/src/WebformGroupManager.php \Drupal\webform_group\WebformGroupManager::getCurrentGroupContent()
Get the group content for the current request.
Return value
\Drupal\group\Entity\GroupContentInterface|bool The group content for the current request. FALSE if no group content is found for the current request.
Overrides WebformGroupManagerInterface::getCurrentGroupContent
2 calls to WebformGroupManager::getCurrentGroupContent()
- WebformGroupManager::getCurrentGroupWebform in modules/
webform_group/ src/ WebformGroupManager.php - Get the group webform for the current request.
- WebformGroupManager::getCurrentUserGroupRoles in modules/
webform_group/ src/ WebformGroupManager.php - Get the current user's group roles.
File
- modules/
webform_group/ src/ WebformGroupManager.php, line 152
Class
- WebformGroupManager
- Webform group manager manager.
Namespace
Drupal\webform_groupCode
public function getCurrentGroupContent() {
if (isset($this->currentGroupContent)) {
return $this->currentGroupContent;
}
$this->currentGroupContent = FALSE;
$source_entity = $this->requestHandler
->getCurrentSourceEntity([
'webform_submission',
]);
if (!$source_entity) {
return $this->currentGroupContent;
}
/** @var \Drupal\group\Entity\Storage\GroupContentStorageInterface $group_content_storage */
$group_content_storage = $this->entityTypeManager
->getStorage('group_content');
// Get group content id for the source entity.
$group_content_ids = $group_content_storage
->getQuery()
->condition('entity_id', $source_entity
->id())
->execute();
/** @var \Drupal\group\Entity\GroupContentInterface[] $group_contents */
$group_contents = $group_content_storage
->loadMultiple($group_content_ids);
foreach ($group_contents as $group_content) {
$group_content_entity = $group_content
->getEntity();
if ($group_content_entity
->getEntityTypeId() === $source_entity
->getEntityTypeId() && $group_content_entity
->id() === $source_entity
->id()) {
$this->currentGroupContent = $group_content;
break;
}
}
return $this->currentGroupContent;
}