FormFactory.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Customer Form Element Factory
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Customer\Model\Metadata;
  9. class FormFactory
  10. {
  11. /**
  12. * @var \Magento\Framework\ObjectManagerInterface
  13. */
  14. protected $_objectManager;
  15. /**
  16. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  17. */
  18. public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
  19. {
  20. $this->_objectManager = $objectManager;
  21. }
  22. /**
  23. * Create Form
  24. *
  25. * @param string $entityType
  26. * @param string $formCode
  27. * @param array $attributeValues Key is attribute code.
  28. * @param bool $isAjax
  29. * @param bool $ignoreInvisible
  30. * @param array $filterAttributes
  31. * @return \Magento\Customer\Model\Metadata\Form
  32. */
  33. public function create(
  34. $entityType,
  35. $formCode,
  36. array $attributeValues = [],
  37. $isAjax = false,
  38. $ignoreInvisible = Form::IGNORE_INVISIBLE,
  39. $filterAttributes = []
  40. ) {
  41. $params = [
  42. 'entityType' => $entityType,
  43. 'formCode' => $formCode,
  44. 'attributeValues' => $attributeValues,
  45. 'ignoreInvisible' => $ignoreInvisible,
  46. 'filterAttributes' => $filterAttributes,
  47. 'isAjax' => $isAjax,
  48. ];
  49. return $this->_objectManager->create(\Magento\Customer\Model\Metadata\Form::class, $params);
  50. }
  51. }