EntityStorageFactory.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Search\Dynamic;
  7. use Magento\Framework\ObjectManagerInterface;
  8. /**
  9. * EntityStorage Factory
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class EntityStorageFactory
  14. {
  15. /**
  16. * Object Manager instance
  17. *
  18. * @var ObjectManagerInterface
  19. */
  20. protected $objectManager = null;
  21. /**
  22. * Instance name to create
  23. *
  24. * @var string
  25. */
  26. protected $instanceName = null;
  27. /**
  28. * Factory constructor
  29. *
  30. * @param ObjectManagerInterface $objectManager
  31. * @param string $instanceName
  32. */
  33. public function __construct(
  34. ObjectManagerInterface $objectManager,
  35. $instanceName = \Magento\Framework\Search\Dynamic\EntityStorage::class
  36. ) {
  37. $this->objectManager = $objectManager;
  38. $this->instanceName = $instanceName;
  39. }
  40. /**
  41. * Create class instance with specified parameters
  42. *
  43. * @param array $source
  44. * @return \Magento\Framework\Search\Dynamic\EntityStorage
  45. */
  46. public function create($source)
  47. {
  48. return $this->objectManager->create($this->instanceName, ['source' => $source]);
  49. }
  50. }