DataFactory.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Authorizenet\Helper;
  8. use Magento\Framework\Exception\LocalizedException;
  9. use Magento\Framework\ObjectManagerInterface;
  10. /**
  11. * Class DataFactory
  12. * @deprecated 100.3.1 Authorize.net is removing all support for this payment method
  13. */
  14. class DataFactory
  15. {
  16. const AREA_FRONTEND = 'frontend';
  17. const AREA_BACKEND = 'adminhtml';
  18. /**
  19. * @var ObjectManagerInterface
  20. */
  21. protected $objectManager;
  22. /**
  23. * @var array
  24. */
  25. protected $helperMap = [
  26. self::AREA_FRONTEND => \Magento\Authorizenet\Helper\Data::class,
  27. self::AREA_BACKEND => \Magento\Authorizenet\Helper\Backend\Data::class
  28. ];
  29. /**
  30. * Constructor
  31. *
  32. * @param ObjectManagerInterface $objectManager
  33. */
  34. public function __construct(ObjectManagerInterface $objectManager)
  35. {
  36. $this->objectManager = $objectManager;
  37. }
  38. /**
  39. * Create data helper
  40. *
  41. * @param string $area
  42. * @return \Magento\Authorizenet\Helper\Backend\Data|\Magento\Authorizenet\Helper\Data
  43. * @throws LocalizedException
  44. */
  45. public function create($area)
  46. {
  47. if (!isset($this->helperMap[$area])) {
  48. throw new LocalizedException(__(sprintf('For this area <%s> no suitable helper', $area)));
  49. }
  50. return $this->objectManager->get($this->helperMap[$area]);
  51. }
  52. }