Generic.php 893 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Dhl\Model\Source\Method;
  7. class Generic
  8. {
  9. /**
  10. * @var \Magento\Dhl\Model\Carrier
  11. */
  12. protected $_shippingDhl;
  13. /**
  14. * @var string
  15. */
  16. protected $_code = '';
  17. /**
  18. * @param \Magento\Dhl\Model\Carrier $shippingDhl
  19. */
  20. public function __construct(\Magento\Dhl\Model\Carrier $shippingDhl)
  21. {
  22. $this->_shippingDhl = $shippingDhl;
  23. }
  24. /**
  25. * Returns array to be used in multiselect on back-end
  26. *
  27. * @return array
  28. */
  29. public function toOptionArray()
  30. {
  31. $configData = $this->_shippingDhl->getCode($this->_code);
  32. $arr = [];
  33. foreach ($configData as $code => $title) {
  34. $arr[] = ['value' => $code, 'label' => $title];
  35. }
  36. return $arr;
  37. }
  38. }