Skip to content

Commit

Permalink
Fixed default config for status mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
FATCHIP-GmbH committed Dec 2, 2016
1 parent 09eca56 commit 3377f43
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
59 changes: 59 additions & 0 deletions Block/Adminhtml/Config/Form/Field/StatusMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ class StatusMapping extends \Magento\Config\Block\System\Config\Form\Field\Field
* @var \Payone\Core\Model\Source\TransactionStatus
*/
protected $transactionStatus;

/**
* Rows cache
*
* @var array|null
*/
private $_arrayRowsCache;

/**
* Constructor
Expand Down Expand Up @@ -117,4 +124,56 @@ public function renderCellTemplate($columnName)
);
return str_replace("\n", '', $oElement->getElementHtml());
}

/**
* Obtain existing data from form element
*
* Each row will be instance of \Magento\Framework\DataObject
*
* @return array
*/
public function getArrayRows()
{
if (null !== $this->_arrayRowsCache) {
return $this->_arrayRowsCache;
}
$result = [];
/** @var \Magento\Framework\Data\Form\Element\AbstractElement */
$element = $this->getElement();
$aValue = $element->getValue();
if (!is_array($aValue)) {
$aValue = unserialize($aValue);
}

if ($aValue && is_array($aValue)) {
foreach ($aValue as $rowId => $row) {
$rowColumnValues = [];
foreach ($row as $key => $value) {
$row[$key] = $value;
$rowColumnValues[$this->_getCellInputElementId($rowId, $key)] = $row[$key];
}
$row['_id'] = $rowId;
$row['column_values'] = $rowColumnValues;
$result[$rowId] = new \Magento\Framework\DataObject($row);
$this->_prepareArrayRow($result[$rowId]);
}
}
$this->_arrayRowsCache = $result;
return $this->_arrayRowsCache;
}

/**
* Get the grid and scripts contents
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return string
*/
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
$this->setElement($element);
$html = $this->_toHtml();
$this->_arrayRowsCache = null;
// doh, the object is used as singleton!
return $html;
}
}
2 changes: 1 addition & 1 deletion Model/PayoneConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
abstract class PayoneConfig
{
/* Module version */
const MODULE_VERSION = '1.2.4';
const MODULE_VERSION = '1.2.5';

/* Authorization request types */
const REQUEST_TYPE_PREAUTHORIZATION = 'preauthorization';
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Payone_Core" setup_version="1.2.4" />
<module name="Payone_Core" setup_version="1.2.5" />
</config>

0 comments on commit 3377f43

Please sign in to comment.