You are here

public function ViewsJsonQuery::ops in Views Json Source 8

Same name and namespace in other branches
  1. 1.x src/Plugin/views/query/ViewsJsonQuery.php \Drupal\views_json_source\Plugin\views\query\ViewsJsonQuery::ops()

Define ops for using in filter.

1 call to ViewsJsonQuery::ops()
ViewsJsonQuery::parse in src/Plugin/views/query/ViewsJsonQuery.php
Parse.

File

src/Plugin/views/query/ViewsJsonQuery.php, line 296

Class

ViewsJsonQuery
Base query handler for views_json_source.

Namespace

Drupal\views_json_source\Plugin\views\query

Code

public function ops($op, $l, $r) {
  $table = [
    '=' => function ($l, $r) {
      return $l == $r;
    },
    '!=' => function ($l, $r) {
      return $l != $r;
    },
    'contains' => function ($l, $r) {
      return strpos($l, $r) !== FALSE;
    },
    '!contains' => function ($l, $r) {
      return strpos($l, $r) === FALSE;
    },
    'shorterthan' => function ($l, $r) {
      return strlen($l) < $r;
    },
    'longerthan' => function ($l, $r) {
      return strlen($l) > $r;
    },
  ];
  return call_user_func_array($table[$op], [
    $l,
    $r,
  ]);
}