DataFactory.php 1.1 KB

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