Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FormFactory.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Framework\Data;
8 
13 {
19  protected $_objectManager;
20 
26  protected $_instanceName;
27 
34  public function __construct(
36  $instanceName = \Magento\Framework\Data\Form::class
37  ) {
38  $this->_objectManager = $objectManager;
39  $this->_instanceName = $instanceName;
40  }
41 
49  public function create(array $data = [])
50  {
52  $form = $this->_objectManager->create($this->_instanceName, $data);
53  if (!$form instanceof \Magento\Framework\Data\Form) {
54  throw new \Magento\Framework\Exception\LocalizedException(
55  new \Magento\Framework\Phrase(
56  '%1 doesn\'t extend \Magento\Framework\Data\Form',
57  [$this->_instanceName]
58  )
59  );
60  }
61  return $form;
62  }
63 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\Data\Form::class)
Definition: FormFactory.php:34