You are here

protected function WebformOptionsCustomListBuilder::getQuery in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php \Drupal\webform_options_custom\WebformOptionsCustomListBuilder::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 WebformOptionsCustomListBuilder::getQuery()
WebformOptionsCustomListBuilder::getEntityIds in modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php
Loads entity IDs using a pager sorted by the entity label (instead of id).

File

modules/webform_options_custom/src/WebformOptionsCustomListBuilder.php, line 260

Class

WebformOptionsCustomListBuilder
Defines a class to build a listing of webform options custom entities.

Namespace

Drupal\webform_options_custom

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('description', $keys, 'CONTAINS')
      ->condition('help', $keys, 'CONTAINS')
      ->condition('template', $keys, 'CONTAINS')
      ->condition('url', $keys, 'CONTAINS')
      ->condition('options', $keys, 'CONTAINS');
    $query
      ->condition($or);
  }

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