Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ValueFactory.php
Go to the documentation of this file.
1 <?php
7 
12 {
18  protected $_objectManager = null;
19 
25  protected $_instanceName = null;
26 
33  public function __construct(
35  $instanceName = \Magento\Framework\App\Config\ValueInterface::class
36  ) {
37  $this->_objectManager = $objectManager;
38  $this->_instanceName = $instanceName;
39  }
40 
48  public function create(array $data = [])
49  {
50  $model = $this->_objectManager->create($this->_instanceName, $data);
51  if (!$model instanceof \Magento\Framework\App\Config\ValueInterface) {
52  throw new \InvalidArgumentException('Invalid config field model: ' . $this->_instanceName);
53  }
54  return $model;
55  }
56 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\App\Config\ValueInterface::class)