Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigurableObject.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  protected $objectManager;
20 
25 
33  {
34  $this->objectManager = $objectManager;
35  $this->argumentInterpreter = $argumentInterpreter;
36  }
37 
41  public function evaluate(array $data)
42  {
43  if (isset($data['value'])) {
44  $className = $data['value'];
45  $arguments = [];
46  } else {
47  if (!isset($data['argument'])) {
48  throw new \InvalidArgumentException('Node "argument" required for this type.');
49  }
50  foreach ($data['argument'] as $name => $argument) {
51  $arguments[$name] = $this->argumentInterpreter->evaluate($argument);
52  }
53  if (!isset($arguments['class'])) {
54  throw new \InvalidArgumentException('Node "argument" with name "class" is required for this type.');
55  }
56  $className = $arguments['class'];
57  unset($arguments['class']);
58  }
59 
60  return $this->objectManager->create($className, $arguments);
61  }
62 }
$arguments
__construct(ObjectManagerInterface $objectManager, InterpreterInterface $argumentInterpreter)
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31
if(!isset($_GET['name'])) $name
Definition: log.php:14