Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ArrayNodeConfig.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  private $nodePathMatcher;
17 
23  private $assocArrays = [];
24 
30  private $numericArrays = [];
31 
37  public function __construct(
38  NodePathMatcher $nodePathMatcher,
39  array $assocArrayAttributes,
40  array $numericArrays = []
41  ) {
42  $this->nodePathMatcher = $nodePathMatcher;
43  $this->assocArrays = $assocArrayAttributes;
44  $this->numericArrays = $numericArrays;
45  }
46 
53  public function isNumericArray($nodeXpath)
54  {
55  foreach ($this->numericArrays as $pathPattern) {
56  if ($this->nodePathMatcher->match($pathPattern, $nodeXpath)) {
57  return true;
58  }
59  }
60  return false;
61  }
62 
69  public function getAssocArrayKeyAttribute($nodeXpath)
70  {
71  foreach ($this->assocArrays as $pathPattern => $keyAttribute) {
72  if ($this->nodePathMatcher->match($pathPattern, $nodeXpath)) {
73  return $keyAttribute;
74  }
75  }
76  return null;
77  }
78 }
$pathPattern
__construct(NodePathMatcher $nodePathMatcher, array $assocArrayAttributes, array $numericArrays=[])