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