You are here

public function NodeExtension::translateNegation in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/css-selector/XPath/Extension/NodeExtension.php \Symfony\Component\CssSelector\XPath\Extension\NodeExtension::translateNegation()

Parameters

Node\NegationNode $node:

Translator $translator:

Return value

XPathExpr

File

vendor/symfony/css-selector/XPath/Extension/NodeExtension.php, line 122

Class

NodeExtension
XPath expression translator node extension.

Namespace

Symfony\Component\CssSelector\XPath\Extension

Code

public function translateNegation(Node\NegationNode $node, Translator $translator) {
  $xpath = $translator
    ->nodeToXPath($node
    ->getSelector());
  $subXpath = $translator
    ->nodeToXPath($node
    ->getSubSelector());
  $subXpath
    ->addNameTest();
  if ($subXpath
    ->getCondition()) {
    return $xpath
      ->addCondition(sprintf('not(%s)', $subXpath
      ->getCondition()));
  }
  return $xpath
    ->addCondition('0');
}