|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* For full license information, please view the LICENSE file that was distributed with this source code. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Braintree\Communication\Table; |
|
9
|
|
|
|
|
10
|
|
|
use Orm\Zed\Braintree\Persistence\Map\SpyPaymentBraintreeTransactionStatusLogTableMap; |
|
|
|
|
|
|
11
|
|
|
use Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLogQuery; |
|
|
|
|
|
|
12
|
|
|
use Spryker\Zed\Gui\Communication\Table\AbstractTable; |
|
13
|
|
|
use Spryker\Zed\Gui\Communication\Table\TableConfiguration; |
|
14
|
|
|
|
|
15
|
|
|
class StatusLog extends AbstractTable implements BraintreeTableInterface |
|
16
|
|
|
{ |
|
17
|
|
|
public const FIELD_DETAILS = 'FIELD_DETAILS'; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLogQuery |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $statusLogQuery; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var int |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $idPayment; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string[] |
|
31
|
|
|
*/ |
|
32
|
|
|
protected static $includeFields = [ |
|
33
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_ID, |
|
34
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_CODE, |
|
35
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_STATUS, |
|
36
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_TYPE, |
|
37
|
|
|
]; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param \Orm\Zed\Braintree\Persistence\SpyPaymentBraintreeTransactionStatusLogQuery $statusLogQuery |
|
41
|
|
|
* @param int $idPayment |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct(SpyPaymentBraintreeTransactionStatusLogQuery $statusLogQuery, $idPayment) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->statusLogQuery = $statusLogQuery; |
|
46
|
|
|
$this->idPayment = $idPayment; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config |
|
51
|
|
|
* |
|
52
|
|
|
* @return \Spryker\Zed\Gui\Communication\Table\TableConfiguration |
|
53
|
|
|
*/ |
|
54
|
|
|
protected function configure(TableConfiguration $config) |
|
55
|
|
|
{ |
|
56
|
|
|
$config->setHeader($this->getHeaderFields()); |
|
57
|
|
|
$config->setSortable([ |
|
58
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::COL_TRANSACTION_ID, |
|
59
|
|
|
]); |
|
60
|
|
|
$config->setUrl('status-log-table?id-payment=' . $this->idPayment); |
|
61
|
|
|
|
|
62
|
|
|
return $config; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return array |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function getHeaderFields() |
|
69
|
|
|
{ |
|
70
|
|
|
$headerFields = []; |
|
71
|
|
|
foreach (static::$includeFields as $fieldName) { |
|
72
|
|
|
$translatedFieldName = SpyPaymentBraintreeTransactionStatusLogTableMap::translateFieldName( |
|
73
|
|
|
$fieldName, |
|
74
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_COLNAME, |
|
75
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_FIELDNAME |
|
76
|
|
|
); |
|
77
|
|
|
|
|
78
|
|
|
$fieldLabel = str_replace(['processing_', 'identification_'], '', $translatedFieldName); |
|
79
|
|
|
$headerFields[$translatedFieldName] = $fieldLabel; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
$headerFields[static::FIELD_DETAILS] = 'Details'; |
|
83
|
|
|
|
|
84
|
|
|
return $headerFields; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config |
|
89
|
|
|
* |
|
90
|
|
|
* @return array |
|
91
|
|
|
*/ |
|
92
|
|
|
protected function prepareData(TableConfiguration $config) |
|
93
|
|
|
{ |
|
94
|
|
|
$logItems = $this->runQuery($this->statusLogQuery, $config); |
|
95
|
|
|
$results = []; |
|
96
|
|
|
foreach ($logItems as $logItem) { |
|
97
|
|
|
$results[] = $this->getFieldMatchedResultArrayFromLogItem($logItem); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return $results; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Returns an array that matches field values from $logItem with the table's |
|
105
|
|
|
* fields so that it renders correctly assigned field. |
|
106
|
|
|
* |
|
107
|
|
|
* @param array $logItem |
|
108
|
|
|
* |
|
109
|
|
|
* @return array |
|
110
|
|
|
*/ |
|
111
|
|
|
protected function getFieldMatchedResultArrayFromLogItem(array $logItem) |
|
112
|
|
|
{ |
|
113
|
|
|
$resultArray = []; |
|
114
|
|
|
foreach (static::$includeFields as $fieldName) { |
|
115
|
|
|
$translatedFieldName = SpyPaymentBraintreeTransactionStatusLogTableMap::translateFieldName( |
|
116
|
|
|
$fieldName, |
|
117
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_COLNAME, |
|
118
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_FIELDNAME |
|
119
|
|
|
); |
|
120
|
|
|
|
|
121
|
|
|
$resultArray[$translatedFieldName] = $logItem[$fieldName]; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
$resultArray[static::FIELD_DETAILS] = $this->getDetailsFieldValue($logItem); |
|
125
|
|
|
|
|
126
|
|
|
return $resultArray; |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Dumps all remaining fields (and their values) into a single string representation. |
|
131
|
|
|
* |
|
132
|
|
|
* @param array $logItem |
|
133
|
|
|
* |
|
134
|
|
|
* @return string |
|
135
|
|
|
*/ |
|
136
|
|
|
protected function getDetailsFieldValue(array $logItem) |
|
137
|
|
|
{ |
|
138
|
|
|
$fieldNames = SpyPaymentBraintreeTransactionStatusLogTableMap::getFieldNames( |
|
139
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_COLNAME |
|
140
|
|
|
); |
|
141
|
|
|
$tupleRows = []; |
|
142
|
|
|
foreach ($fieldNames as $fieldName) { |
|
143
|
|
|
if (in_array($fieldName, static::$includeFields)) { |
|
144
|
|
|
continue; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
$translatedFieldName = SpyPaymentBraintreeTransactionStatusLogTableMap::translateFieldName( |
|
148
|
|
|
$fieldName, |
|
149
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_COLNAME, |
|
150
|
|
|
SpyPaymentBraintreeTransactionStatusLogTableMap::TYPE_FIELDNAME |
|
151
|
|
|
); |
|
152
|
|
|
|
|
153
|
|
|
$tupleRows[] = sprintf('%s: %s', $translatedFieldName, $logItem[$fieldName]); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
$detailsText = implode('<br />', $tupleRows); |
|
157
|
|
|
|
|
158
|
|
|
return $detailsText; |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths