Factory.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Pricing\Adjustment;
  7. /**
  8. * Adjustment factory
  9. */
  10. class Factory
  11. {
  12. /**
  13. * Object Manager
  14. *
  15. * @var \Magento\Framework\ObjectManagerInterface
  16. */
  17. protected $objectManager;
  18. /**
  19. * Construct
  20. *
  21. * @param \Magento\Framework\ObjectManagerInterface $objectManager
  22. */
  23. public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
  24. {
  25. $this->objectManager = $objectManager;
  26. }
  27. /**
  28. * Create shared price adjustment
  29. *
  30. * @param string $className
  31. * @param array $arguments
  32. * @return \Magento\Framework\Pricing\Adjustment\AdjustmentInterface
  33. * @throws \InvalidArgumentException
  34. */
  35. public function create($className, array $arguments = [])
  36. {
  37. $adjustment = $this->objectManager->create($className, $arguments);
  38. if (!$adjustment instanceof AdjustmentInterface) {
  39. throw new \InvalidArgumentException(
  40. $className . ' doesn\'t implement \Magento\Framework\Pricing\Adjustment\AdjustmentInterface'
  41. );
  42. }
  43. return $adjustment;
  44. }
  45. }