You are here

protected function YamlFormSubmissionListBuilder::getQuery in YAML Form 8

Get the base entity query filtered by form and search.

Parameters

string $keys: (optional) Search key.

string $state: (optional) Submission state. Can be 'starred' or 'unstarred'.

Return value

\Drupal\Core\Entity\Query\QueryInterface An entity query.

1 call to YamlFormSubmissionListBuilder::getQuery()
YamlFormSubmissionListBuilder::getEntityIds in src/YamlFormSubmissionListBuilder.php
Loads entity IDs using a pager sorted by the entity id.

File

src/YamlFormSubmissionListBuilder.php, line 610

Class

YamlFormSubmissionListBuilder
Provides a list controller for yamlform submission entity.

Namespace

Drupal\yamlform

Code

protected function getQuery($keys = '', $state = '') {
  $query = $this
    ->getStorage()
    ->getQuery();
  $this
    ->addQueryConditions($query);

  // Filter by key(word).
  if ($keys) {
    $sub_query = Database::getConnection()
      ->select('yamlform_submission_data', 'sd')
      ->fields('sd', [
      'sid',
    ])
      ->condition('value', '%' . $keys . '%', 'LIKE');
    $this
      ->addQueryConditions($sub_query);
    $or = $query
      ->orConditionGroup()
      ->condition('sid', $sub_query, 'IN')
      ->condition('notes', '%' . $keys . '%', 'LIKE');
    $query
      ->condition($or);
  }

  // Filter by (submission) state.
  if ($state == self::STATE_STARRED || $state == self::STATE_UNSTARRED) {
    $query
      ->condition('sticky', $state == self::STATE_STARRED ? 1 : 0);
  }
  return $query;
}