You are here

public function StringContainsArgument::query in Media Directories 8

Same name and namespace in other branches
  1. 2.x modules/media_directories_ui/src/Plugin/views/argument/StringContainsArgument.php \Drupal\media_directories_ui\Plugin\views\argument\StringContainsArgument::query()

Set up the query for this argument.

The argument sent may be found at $this->argument.

Overrides ArgumentPluginBase::query

File

modules/media_directories_ui/src/Plugin/views/argument/StringContainsArgument.php, line 73

Class

StringContainsArgument
Media directory ui string contains argument plugin.

Namespace

Drupal\media_directories_ui\Plugin\views\argument

Code

public function query($group_by = FALSE) {
  $this
    ->ensureMyTable();
  $this->value = $this->argument;
  $placeholder = $this
    ->placeholder();

  // empty($this->options['not']) ? '' : " OR $this->tableAlias.$this->realField IS NULL";.
  $null_check = '';
  if (!empty($this->value)) {
    $operator = empty($this->options['not']) ? 'LIKE' : 'NOT LIKE';
    $this->query
      ->addWhereExpression(0, "{$this->tableAlias}.{$this->realField} {$operator} {$placeholder}" . $null_check, [
      $placeholder => '%' . $this->argument . '%',
    ]);
  }
}