Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ModelFactory.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_objectManager;
17 
22  {
23  $this->_objectManager = $objectManager;
24  }
25 
34  public function create($model, array $data = [])
35  {
36  $modelInstance = $this->_objectManager->create($model, $data);
37  if (false == $modelInstance instanceof \Magento\Framework\Model\AbstractModel) {
38  throw new \InvalidArgumentException($model . ' is not instance of \Magento\Framework\Model\AbstractModel');
39  }
40  return $modelInstance;
41  }
42 }
__construct(\Magento\Framework\ObjectManagerInterface $objectManager)
$objectManager
Definition: bootstrap.php:17