/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/Config/Dom/NodePathMatcher.php
40 строк
1 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\Config\Dom; /** * Matching of XPath expressions to path patterns */ class NodePathMatcher { /** * Whether a subject XPath matches to a given path pattern * * @param string $pathPattern Example: '/some/static/path' or '/some/regexp/path(/item)+' * @param string $xpathSubject Example: '/some[@attr="value"]/static/ns:path' * @return bool */ public function match($pathPattern, $xpathSubject) { $pathSubject = $this->simplifyXpath($xpathSubject); $pathPattern = '#^' . $pathPattern . '$#'; return (bool)preg_match($pathPattern, $pathSubject); } /** * Strip off predicates and namespaces from the XPath * * @param string $xpath * @return string */ protected function simplifyXpath($xpath) { $result = $xpath ?: ''; $result = preg_replace('/\[@[^\]]+?\]/', '', $result); return preg_replace('/\/[^:]+?\:/', '/', $result); } }