Automattic\WooCommerce\EmailEditorVendor\Symfony\Component\CssSelector

CssSelectorConverter::toXPath │ public │ WC 1.0

Translates a CSS expression to its XPath equivalent.

Optionally, a prefix can be added to the resulting XPath expression with the $prefix parameter.

Метод класса: CssSelectorConverter{}

Хуков нет.

Возвращает

string.

Использование

$CssSelectorConverter = new CssSelectorConverter();
$CssSelectorConverter->toXPath( $cssExpr, $prefix );
$cssExpr(строка) (обязательный)
.
$prefix(строка)
.
По умолчанию: 'descendant-or-self::'

Код CssSelectorConverter::toXPath() WC 11.2.2

public function toXPath(string $cssExpr, string $prefix = 'descendant-or-self::')
{
    if (isset($this->cache[$prefix][$cssExpr])) {
        // Promote to most-recently-used position.
        $value = $this->cache[$prefix][$cssExpr];
        unset($this->cache[$prefix][$cssExpr]);

        return $this->cache[$prefix][$cssExpr] = $value;
    }

    $value = $this->translator->cssToXPath($cssExpr, $prefix);

    if (\count($this->cache[$prefix] ?? []) >= self::$maxCachedItems) {
        // Evict least-recently-used entry.
        unset($this->cache[$prefix][\array_key_first($this->cache[$prefix])]);
    }

    return $this->cache[$prefix][$cssExpr] = $value;
}