DocumentFactory.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Api\Search;
  7. class DocumentFactory
  8. {
  9. /**
  10. * Object manager
  11. *
  12. * @var \Magento\Framework\ObjectManagerInterface
  13. */
  14. protected $_objectManager;
  15. /**
  16. * Instance name to create
  17. *
  18. * @var string
  19. */
  20. protected $_instanceName = null;
  21. /**
  22. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  23. * @param string $instanceName
  24. */
  25. public function __construct(
  26. \Magento\Framework\ObjectManagerInterface $objectManager,
  27. $instanceName = \Magento\Framework\Api\Search\Document::class
  28. ) {
  29. $this->_objectManager = $objectManager;
  30. $this->_instanceName = $instanceName;
  31. }
  32. /**
  33. * Create class instance with specified parameters
  34. *
  35. * @param array $data
  36. * @return DocumentInterface
  37. */
  38. public function create(array $data = [])
  39. {
  40. return $this->_objectManager->create($this->_instanceName, $data);
  41. }
  42. }