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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Braintree\Gateway\Request;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ProductMetadataInterface;
use Magento\Payment\Gateway\Config\Config;
use Magento\Payment\Gateway\Request\BuilderInterface;
/**
* Class BnCodeDataBuilder
*/
class ChannelDataBuilder implements BuilderInterface
{
/**
* @var string
*/
private static $channel = 'channel';
/**
* @var string
*/
private static $channelValue = 'Magento2_Cart_%s_BT';
/**
* @var ProductMetadataInterface
*/
private $productMetadata;
/**
* @var Config
*/
private $config;
/**
* Constructor
*
* @param ProductMetadataInterface $productMetadata
* @param Config $config
*/
public function __construct(ProductMetadataInterface $productMetadata, Config $config = null)
{
$this->productMetadata = $productMetadata;
$this->config = $config ?: ObjectManager::getInstance()->get(Config::class);
}
/**
* @inheritdoc
*/
public function build(array $buildSubject)
{
$channel = $this->config->getValue('channel');
return [
self::$channel => $channel ?: sprintf(self::$channelValue, $this->productMetadata->getEdition())
];
}
}