public function FunctionExtension::translateContains in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php \Symfony\Component\CssSelector\XPath\Extension\FunctionExtension::translateContains()
Parameters
XPathExpr $xpath:
FunctionNode $function:
Return value
Throws
File
- vendor/
symfony/ css-selector/ XPath/ Extension/ FunctionExtension.php, line 158
Class
- FunctionExtension
- XPath expression translator function extension.
Namespace
Symfony\Component\CssSelector\XPath\ExtensionCode
public function translateContains(XPathExpr $xpath, FunctionNode $function) {
$arguments = $function
->getArguments();
foreach ($arguments as $token) {
if (!($token
->isString() || $token
->isIdentifier())) {
throw new ExpressionErrorException('Expected a single string or identifier for :contains(), got ' . implode(', ', $arguments));
}
}
return $xpath
->addCondition(sprintf('contains(string(.), %s)', Translator::getXpathLiteral($arguments[0]
->getValue())));
}