Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigurableObjectType.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
18  private $argumentParser;
19 
23  public function __construct(ParserInterface $argumentParser)
24  {
25  $this->argumentParser = $argumentParser;
26  }
27 
32  public function parse(array $data, \DOMNode $node)
33  {
34  $arguments = isset($data['argument']) ? $data['argument'] : [];
35  if (!is_array($arguments)) {
36  throw new \InvalidArgumentException('Array arguments are expected.');
37  }
38  $result = [];
39  foreach ($arguments as $argumentKey => $argumentData) {
40  $parserResult = $this->argumentParser->parse($argumentData, $node);
41  if ($parserResult) {
42  $result[$argumentKey] = $parserResult;
43  }
44  }
45 
46  if ($result) {
47  $data['argument'] = $result;
48  return $data;
49  } else {
50  return $result;
51  }
52  }
53 }
$arguments