ConfigValueHandler.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Gateway\Config;
  7. use Magento\Payment\Gateway\ConfigInterface;
  8. use Magento\Payment\Gateway\Helper\SubjectReader;
  9. /**
  10. * Default implementation of config value handler.
  11. *
  12. * This class is designed to be injected into other classes. Inheritance in not recommended.
  13. *
  14. * @api
  15. * @since 100.0.2
  16. */
  17. class ConfigValueHandler implements ValueHandlerInterface
  18. {
  19. /**
  20. * @var \Magento\Payment\Gateway\ConfigInterface
  21. */
  22. private $configInterface;
  23. /**
  24. * @param \Magento\Payment\Gateway\ConfigInterface $configInterface
  25. */
  26. public function __construct(
  27. ConfigInterface $configInterface
  28. ) {
  29. $this->configInterface = $configInterface;
  30. }
  31. /**
  32. * Retrieve method configured value
  33. *
  34. * @param array $subject
  35. * @param int|null $storeId
  36. *
  37. * @return mixed
  38. */
  39. public function handle(array $subject, $storeId = null)
  40. {
  41. return $this->configInterface->getValue(SubjectReader::readField($subject), $storeId);
  42. }
  43. }