Skip to content

Commit

Permalink
Merge pull request #14 from limegrow/releases/v2.8.1
Browse files Browse the repository at this point in the history
Bump v2.8.1
  • Loading branch information
olegisk authored May 27, 2021
2 parents e07bd7e + 9d98b4f commit 20eef5c
Show file tree
Hide file tree
Showing 9 changed files with 773 additions and 563 deletions.
44 changes: 37 additions & 7 deletions Block/Adminhtml/System/Config/Support/Settings/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,58 @@

namespace Ingenico\Payment\Block\Adminhtml\System\Config\Support\Settings;

use Magento\Config\Block\System\Config\Form\Field;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Data\Form\Element\AbstractElement;
use Magento\Backend\Model\UrlInterface as BackendUrlInterface;
use Magento\Framework\UrlInterface;

/**
* Provides field with additional information
*/
class Export extends \Magento\Config\Block\System\Config\Form\Field
class Export extends Field
{
protected $_connector;
/**
* @var UrlInterface
*/
private $urlBuilder;

/**
* @var BackendUrlInterface
*/
private $backendUrlBuilder;

public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Ingenico\Payment\Model\Connector $connector,
Context $context,
UrlInterface $urlBuilder,
BackendUrlInterface $backendUrlBuilder,
array $data = []
) {
$this->_connector = $connector;
$this->urlBuilder = $urlBuilder;
$this->backendUrlBuilder = $backendUrlBuilder;

parent::__construct($context, $data);
}

protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
protected function _getElementHtml(AbstractElement $element)
{
$id = $element->getHtmlId();
$link = $this->_connector->getUrl('ingenico/settings/export', [\Ingenico\Payment\Model\Connector::CNF_SCOPE_PARAM_NAME => 0]);
$link = $this->getUrlPath('ingenico/settings/export', ['_scope' => 0]);
return implode('', [
'<a href="' . $link . '">' . __('form.support.download_settings') . '</a>',
]);
}

private function getUrlPath($path, $params = [])
{
$defaultParams = ['_nosid' => true, '_scope' => $this->getStoreId()];
$params = array_merge($defaultParams, $params);

if ($params['_scope'] == 0) {
unset($params['_scope']);
return $this->backendUrlBuilder->getUrl($path, $params);
}

return $this->urlBuilder->getUrl($path, $params);
}
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [2.8.1] - 2021-05-27
### Added
- Klarna: Rounding workaround

### Changed
- Klarna parameters update
- Improved order cancellation code
- Klarna api updates + Order::isVirtual()
- Translation update
- Core library update
- Code style formatting

## [2.8.0] - 2021-05-03
### Added
- Implemented Magento Commerce features
Expand Down
24 changes: 23 additions & 1 deletion Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Magento\Payment\Helper\Data as PaymentHelper;
use Magento\Store\Model\StoreManagerInterface;
use Ingenico\Payment\Model\Method\AbstractMethod;
use Magento\Eav\Model\Config as EavConfig;
use Magento\Sales\Model\Order;

class Data extends AbstractHelper
{
Expand All @@ -33,19 +35,26 @@ class Data extends AbstractHelper
*/
private $storeManager;

/**
* @var EavConfig
*/
private $eavConfig;

public function __construct(
Context $context,
Connector $connector,
IngenicoConfig $cnf,
PaymentHelper $paymentHelper,
StoreManagerInterface $storeManager
StoreManagerInterface $storeManager,
EavConfig $eavConfig
) {
parent::__construct($context);

$this->connector = $connector;
$this->cnf = $cnf;
$this->paymentHelper = $paymentHelper;
$this->storeManager = $storeManager;
$this->eavConfig = $eavConfig;
}

/**
Expand Down Expand Up @@ -166,4 +175,17 @@ public function getStoreId()
{
return $this->storeManager->getStore()->getId();
}

/**
* Get gender text for customer
*
* @param Order $order
*/
public function getGender(Order $order)
{
return $this->eavConfig
->getAttribute('customer', 'gender')
->getSource()
->getOptionText($order->getCustomerGender());
}
}
Loading

0 comments on commit 20eef5c

Please sign in to comment.