Factory.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\ResourceModel\Order\Collection;
  7. class Factory
  8. {
  9. /**
  10. * @var \Magento\Framework\ObjectManagerInterface
  11. */
  12. protected $_objectManager;
  13. /**
  14. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  15. */
  16. public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
  17. {
  18. $this->_objectManager = $objectManager;
  19. }
  20. /**
  21. * @param string $className
  22. * @param array $data
  23. * @return AbstractCollection
  24. * @throws \InvalidArgumentException
  25. */
  26. public function create($className, array $data = [])
  27. {
  28. $instance = $this->_objectManager->create($className, $data);
  29. if (!$instance instanceof AbstractCollection) {
  30. throw new \InvalidArgumentException(
  31. $className .
  32. ' does not implement \Magento\Sales\Model\ResourceModel\Order\Collection\AbstractCollection'
  33. );
  34. }
  35. return $instance;
  36. }
  37. }