AbstractExtension.php
2 years ago
AttributeMatchingExtension.php
2 years ago
CombinationExtension.php
2 years ago
ExtensionInterface.php
2 years ago
FunctionExtension.php
2 years ago
HtmlExtension.php
2 years ago
NodeExtension.php
2 years ago
PseudoClassExtension.php
2 years ago
index.php
2 years ago
CombinationExtension.php
32 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\CssSelector\XPath\Extension; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Component\CssSelector\XPath\XPathExpr; |
| 5 | class CombinationExtension extends AbstractExtension |
| 6 | { |
| 7 | public function getCombinationTranslators() : array |
| 8 | { |
| 9 | return [' ' => [$this, 'translateDescendant'], '>' => [$this, 'translateChild'], '+' => [$this, 'translateDirectAdjacent'], '~' => [$this, 'translateIndirectAdjacent']]; |
| 10 | } |
| 11 | public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath) : XPathExpr |
| 12 | { |
| 13 | return $xpath->join('/descendant-or-self::*/', $combinedXpath); |
| 14 | } |
| 15 | public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath) : XPathExpr |
| 16 | { |
| 17 | return $xpath->join('/', $combinedXpath); |
| 18 | } |
| 19 | public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) : XPathExpr |
| 20 | { |
| 21 | return $xpath->join('/following-sibling::', $combinedXpath)->addNameTest()->addCondition('position() = 1'); |
| 22 | } |
| 23 | public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) : XPathExpr |
| 24 | { |
| 25 | return $xpath->join('/following-sibling::', $combinedXpath); |
| 26 | } |
| 27 | public function getName() : string |
| 28 | { |
| 29 | return 'combination'; |
| 30 | } |
| 31 | } |
| 32 |