You are here

public function Standard::__toString in Views XML Backend 8

Same name in this branch
  1. 8 src/Plugin/views/filter/Standard.php \Drupal\views_xml_backend\Plugin\views\filter\Standard::__toString()
  2. 8 src/Plugin/views/argument/Standard.php \Drupal\views_xml_backend\Plugin\views\argument\Standard::__toString()

Generates an XPath filter string.

Return value

string The XPath filter string.

Overrides XmlFilterInterface::__toString

File

src/Plugin/views/filter/Standard.php, line 114
Contains \Drupal\views_xml_backend\Plugin\views\filter\Standard.

Class

Standard
Default implementation of the base filter plugin.

Namespace

Drupal\views_xml_backend\Plugin\views\filter

Code

public function __toString() {
  $operator = $this->operator;
  $xpath = $this->options['xpath_selector'];
  $value = Xpath::escapeXpathString($this->value);
  if ($operator === '=' || $operator === '!=') {
    return "{$xpath} {$operator} {$value}";
  }
  if (strpos($operator, '!') === 0) {
    $operator = ltrim($operator, '!');
    return "not({$operator}({$xpath}, {$value}))";
  }
  return "{$operator}({$xpath}, {$value})";
}