You are here

public function WebformSubmissionStorage::getSourceEntities in Webform 6.x

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

Get source entities associated for a specified webform.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

array An associative array contain source entities associated for a specified webform grouped by entity type.

Overrides WebformSubmissionStorageInterface::getSourceEntities

1 call to WebformSubmissionStorage::getSourceEntities()
WebformSubmissionStorage::getSourceEntitiesAsOptions in src/WebformSubmissionStorage.php
Get source entities as options for a specified webform.

File

src/WebformSubmissionStorage.php, line 340

Class

WebformSubmissionStorage
Defines the webform submission storage.

Namespace

Drupal\webform

Code

public function getSourceEntities(WebformInterface $webform) {

  /** @var \Drupal\Core\Database\StatementInterface $result */
  $result = $this->database
    ->select('webform_submission', 's')
    ->fields('s', [
    'entity_type',
    'entity_id',
  ])
    ->condition('webform_id', $webform
    ->id())
    ->condition('entity_type', '', '<>')
    ->isNotNull('entity_type')
    ->condition('entity_id', '', '<>')
    ->isNotNull('entity_id')
    ->distinct()
    ->execute();
  $source_entities = [];
  while ($record = $result
    ->fetchAssoc()) {
    $source_entities[$record['entity_type']][$record['entity_id']] = $record['entity_id'];
  }
  return $source_entities;
}