InstanceFactory.php 973 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Model\Method;
  7. use Magento\Payment\Api\Data\PaymentMethodInterface;
  8. /**
  9. * Payment method instance factory.
  10. */
  11. class InstanceFactory
  12. {
  13. /**
  14. * @var \Magento\Payment\Helper\Data
  15. */
  16. private $helper;
  17. /**
  18. * @param \Magento\Payment\Helper\Data $helper
  19. */
  20. public function __construct(
  21. \Magento\Payment\Helper\Data $helper
  22. ) {
  23. $this->helper = $helper;
  24. }
  25. /**
  26. * Create payment method instance.
  27. *
  28. * @param PaymentMethodInterface $paymentMethod
  29. * @return \Magento\Payment\Model\MethodInterface
  30. */
  31. public function create(PaymentMethodInterface $paymentMethod)
  32. {
  33. $methodInstance = $this->helper->getMethodInstance($paymentMethod->getCode());
  34. $methodInstance->setStore($paymentMethod->getStoreId());
  35. return $methodInstance;
  36. }
  37. }