Symfony\Component\CssSelector\XPathExpr::addCondition PHP Method

addCondition() public method

public addCondition ( $condition )
    public function addCondition($condition)
    {
        if ($this->condition) {
            $this->condition = sprintf('%s and (%s)', $this->condition, $condition);
        } else {
            $this->condition = $condition;
        }
    }

Usage Example

 /**
  * Joins an XPath expression as an adjacent of another.
  *
  * @param XPathExpr     $xpath The parent XPath expression
  * @param NodeInterface $sub   The adjacent XPath expression
  *
  * @return XPathExpr An XPath instance
  */
 protected function _xpath_direct_adjacent($xpath, $sub)
 {
     // when sub immediately follows xpath
     $xpath->join('/following-sibling::', $sub->toXpath());
     $xpath->addNameTest();
     $xpath->addCondition('position() = 1');
     return $xpath;
 }
All Usage Examples Of Symfony\Component\CssSelector\XPathExpr::addCondition