You are here

public function WebformSubmissionStorage::loadByEntities in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformSubmissionStorage.php \Drupal\webform\WebformSubmissionStorage::loadByEntities()

Load webform submissions by their related entity references.

Parameters

\Drupal\webform\WebformInterface|null $webform: (optional) The webform that the submission token is associated with.

\Drupal\Core\Entity\EntityInterface|null $source_entity: (optional) A webform submission source entity.

\Drupal\Core\Session\AccountInterface|null $account: (optional) A user account.

Return value

\Drupal\webform\WebformSubmissionInterface[] An array of webform submission objects indexed by their ids.

Overrides WebformSubmissionStorageInterface::loadByEntities

File

src/WebformSubmissionStorage.php, line 177

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function loadByEntities(WebformInterface $webform = NULL, EntityInterface $source_entity = NULL, AccountInterface $account = NULL) {
  $properties = [];
  if ($webform) {
    $properties['webform_id'] = $webform
      ->id();
  }
  if ($source_entity) {
    $properties['entity_type'] = $source_entity
      ->getEntityTypeId();
    $properties['entity_id'] = $source_entity
      ->id();
  }
  if ($account) {
    $properties['uid'] = $account
      ->id();
  }
  return $this
    ->loadByProperties($properties);
}