public function WebformSubmission::getSourceEntity in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Entity/WebformSubmission.php \Drupal\webform\Entity\WebformSubmission::getSourceEntity()
Gets the webform submission's source entity.
Parameters
bool $translate: (optional) If TRUE the source entity will be translated.
Return value
\Drupal\Core\Entity\EntityInterface|null The entity that this webform submission was created from.
Overrides WebformSubmissionInterface::getSourceEntity
2 calls to WebformSubmission::getSourceEntity()
- WebformSubmission::getSourceUrl in src/
Entity/ WebformSubmission.php - Gets the webform submission's source URL.
- WebformSubmission::getTokenUrl in src/
Entity/ WebformSubmission.php - Gets the webform submission's secure tokenized URL.
File
- src/
Entity/ WebformSubmission.php, line 523
Class
- WebformSubmission
- Defines the WebformSubmission entity.
Namespace
Drupal\webform\EntityCode
public function getSourceEntity($translate = FALSE) {
if ($this->entity_type->value && $this->entity_id->value) {
$entity_type = $this->entity_type->value;
$entity_id = $this->entity_id->value;
$source_entity = $this
->entityTypeManager()
->getStorage($entity_type)
->load($entity_id);
// If translated is set, get the translated source entity.
if ($translate && $source_entity instanceof ContentEntityInterface) {
$langcode = $this
->language()
->getId();
if ($source_entity
->hasTranslation($langcode)) {
$source_entity = $source_entity
->getTranslation($langcode);
}
}
return $source_entity;
}
else {
return NULL;
}
}