Factory.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Eav\Model\Form;
  7. /**
  8. * EAV form object factory
  9. * @api
  10. * @since 100.0.2
  11. */
  12. class Factory
  13. {
  14. /**
  15. * @var \Magento\Framework\ObjectManagerInterface
  16. */
  17. protected $_objectManager;
  18. /**
  19. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  20. * @codeCoverageIgnore
  21. */
  22. public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
  23. {
  24. $this->_objectManager = $objectManager;
  25. }
  26. /**
  27. * Create new form object
  28. *
  29. * @param string $form
  30. * @param array $data
  31. * @throws \InvalidArgumentException
  32. * @return \Magento\Eav\Model\Form
  33. */
  34. public function create($form, array $data = [])
  35. {
  36. $formInstance = $this->_objectManager->create($form, $data);
  37. if (false == $formInstance instanceof \Magento\Eav\Model\Form) {
  38. throw new \InvalidArgumentException($form . ' is not instance of \Magento\Eav\Model\Form');
  39. }
  40. return $formInstance;
  41. }
  42. }