You are here

protected function WebformOptionsListBuilder::getQuery in Webform 6.x

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

Get the base entity query filtered by search and category.

Parameters

string $keys: (optional) Search key.

string $category: (optional) Category.

Return value

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

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

File

src/WebformOptionsListBuilder.php, line 249

Class

WebformOptionsListBuilder
Defines a class to build a listing of webform options entities.

Namespace

Drupal\webform

Code

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

  // Filter by key(word).
  if ($keys) {
    $or = $query
      ->orConditionGroup()
      ->condition('id', $keys, 'CONTAINS')
      ->condition('title', $keys, 'CONTAINS')
      ->condition('options', $keys, 'CONTAINS');
    $query
      ->condition($or);
  }

  // Filter by category.
  if ($category) {
    $query
      ->condition('category', $category);
  }
  return $query;
}