Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefinitionAggregator.php
Go to the documentation of this file.
1 <?php
8 
10 
18 {
22  private $definitionProcessors;
23 
29  public function __construct(array $definitionProcessors)
30  {
31  $this->definitionProcessors = $definitionProcessors;
32  }
33 
37  public function toDefinition(ElementInterface $column)
38  {
39  $type = $column->getType();
40  if (!isset($this->definitionProcessors[$type])) {
41  throw new \InvalidArgumentException(
42  sprintf("Cannot process object to definition for type %s", $type)
43  );
44  }
45 
46  $definitionProcessor = $this->definitionProcessors[$type];
47  return $definitionProcessor->toDefinition($column);
48  }
49 
53  public function fromDefinition(array $data)
54  {
55  $type = $data['type'];
56  if (!isset($this->definitionProcessors[$type])) {
57  throw new \InvalidArgumentException(
58  sprintf("Cannot process definition to array for type %s", $type)
59  );
60  }
61 
62  $definitionProcessor = $this->definitionProcessors[$type];
63  return $definitionProcessor->fromDefinition($data);
64  }
65 }
$type
Definition: item.phtml:13