translateSubstringMatch example

class AttributeMatchingExtension extends AbstractExtension
{
    public function getAttributeMatchingTranslators(): array
    {
        return [
            'exists' => $this->translateExists(...),
            '=' => $this->translateEquals(...),
            '~=' => $this->translateIncludes(...),
            '|=' => $this->translateDashMatch(...),
            '^=' => $this->translatePrefixMatch(...),
            '$=' => $this->translateSuffixMatch(...),
            '*=' => $this->translateSubstringMatch(...),
            '!=' => $this->translateDifferent(...),
        ];
    }

    public function translateExists(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
    {
        return $xpath->addCondition($attribute);
    }

    public function translateEquals(XPathExpr $xpath, string $attribute, ?string $value): XPathExpr
    {
        
Home | Imprint | This part of the site doesn't use cookies.