Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeExtension.php

function NodeExtension::translateAttribute

1 call to NodeExtension::translateAttribute()
NodeExtension::getNodeTranslators in vendor/symfony/css-selector/XPath/Extension/NodeExtension.php
Returns node translators.

File

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

Class

NodeExtension
XPath expression translator node extension.

Namespace

Symfony\Component\CssSelector\XPath\Extension

Code

public function translateAttribute(Node\AttributeNode $node, Translator $translator) : XPathExpr {
    $name = $node->getAttribute();
    $safe = $this->isSafeName($name);
    if ($this->hasFlag(self::ATTRIBUTE_NAME_IN_LOWER_CASE)) {
        $name = strtolower($name);
    }
    if ($node->getNamespace()) {
        $name = \sprintf('%s:%s', $node->getNamespace(), $name);
        $safe = $safe && $this->isSafeName($node->getNamespace());
    }
    $attribute = $safe ? '@' . $name : \sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name));
    $value = $node->getValue();
    $xpath = $translator->nodeToXPath($node->getSelector());
    if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) {
        $value = strtolower($value);
    }
    return $translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal