protected function WebformSubmissionStorage::postLoad in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::postLoad()
Attaches data to entities upon loading.
Parameters
array $entities: Associative array of query results, keyed on the entity ID.
Overrides EntityStorageBase::postLoad
File
- src/
WebformSubmissionStorage.php, line 949
Class
- WebformSubmissionStorage
- Defines the webform submission storage.
Namespace
Drupal\webformCode
protected function postLoad(array &$entities) {
/** @var \Drupal\webform\WebformSubmissionInterface $entity */
$return = parent::postLoad($entities);
foreach ($entities as $entity) {
$this
->invokeWebformElements('postLoad', $entity);
$this
->invokeWebformHandlers('postLoad', $entity);
// If this is an anonymous draft.
// We must add $SESSION to the submission's cache context.
// @see \Drupal\webform\WebformSubmissionStorage::loadDraft
// @todo Add support for 'view own submission' permission.
if ($entity
->isDraft() && $entity
->getOwner()
->isAnonymous()) {
$entity
->addCacheContexts([
'session',
]);
}
}
return $return;
}