Skip to content

Commit

Permalink
[BOT] Migrate release 2.5.0 to GitHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabil Berhouche committed Nov 26, 2020
1 parent 53d638f commit 24ba510
Show file tree
Hide file tree
Showing 301 changed files with 5,710 additions and 17,793 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Payment/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function _construct()
}

/**
* Get URL for back (reset) button
* Get URL for back (reset) button.
*
* @return string
*/
Expand Down
6 changes: 2 additions & 4 deletions Block/Adminhtml/Payment/Redirect/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
class Form extends \Magento\Backend\Block\Widget
{
/**
*
* @var \Magento\Framework\Registry
*/
protected $coreRegistry;

/**
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $coreRegistry
* @param array $data
Expand All @@ -34,7 +32,7 @@ public function __construct(
}

/**
* Get Form data by using ops payment api
* Get Form data by using ops payment api.
*
* @return array
*/
Expand All @@ -44,7 +42,7 @@ public function getFormFields()
}

/**
* Getting gateway url
* Getting gateway url.
*
* @return string
*/
Expand Down
4 changes: 0 additions & 4 deletions Block/Adminhtml/System/Config/Form/Field/CategoryMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@
class CategoryMapping extends \Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\FieldArray\ConfigFieldArray
{
/**
*
* @var \Lyranetwork\Payzen\Model\System\Config\Source\CategoryFactory
*/
protected $payzenCategoryFactory;

/**
*
* @var \Magento\Catalog\Model\CategoryFactory
*/
protected $categoryFactory;

/**
*
* @var bool
*/
protected $staticTable = true;

/**
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Lyranetwork\Payzen\Model\System\Config\Source\CategoryFactory $payzenCategoryFactory
* @param \Magento\Catalog\Model\CategoryFactory $categoryFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function _prepareToRender()
/**
* Obtain existing data from form element.
*
* Each row will be instance of Varien_Object
* Each row will be instance of Varien_Object.
*
* @return array
*/
Expand Down
4 changes: 0 additions & 4 deletions Block/Adminhtml/System/Config/Form/Field/CustgroupOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@
class CustgroupOptions extends \Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\FieldArray\ConfigFieldArray
{
/**
*
* @var \Magento\Customer\Model\GroupFactory
*/
protected $customerGroupFactory;

/**
*
* @var bool
*/
protected $staticTable = true;

/**
*
* @var array
*/
protected $_default = [];

/**
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Customer\Model\GroupFactory $customerGroupFactory
* @param array $data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
abstract class ConfigFieldArray extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
*
* @var bool
*/
protected $staticTable = false;
Expand Down Expand Up @@ -101,6 +100,29 @@ protected function getUploadButtonRenderer($columnName)
return $this->$columnName;
}

/**
* Retrieve list type column renderer.
*
* @return Customergroup
*/
protected function getMultiselectRenderer($columnName, $options)
{
if (! isset($this->$columnName) || ! $this->$columnName) {
$this->$columnName = $this->getLayout()->createBlock(
\Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Renderer\ColumnMultiselect::class,
'',
[
'data' => [
'is_render_to_js_template' => false,
'options' => $options
]
]
);
}

return $this->$columnName;
}

/**
* Retrieve HTML markup for given form element.
*
Expand All @@ -121,40 +143,53 @@ public function render(\Magento\Framework\Data\Form\Element\AbstractElement $ele
}

/**
* Render HTML block.
* Render element JavaScript code.
*
* @return string
*/
protected function _toHtml()
protected function renderScript()
{
$thisEltId = $this->getElement()->getId();

$script = '';

if ($this->_isInheritCheckboxRequired($this->getElement())) {
$script .= '
$script = '
<script>
require([
"prototype"
], function () {
document.observe("dom:loaded", function() {
toggleValueElements($("' . $thisEltId . '_inherit"), $("' . $thisEltId . '"));';
';

$script .= ' toggleValueElements($("' . $thisEltId . '_inherit"), $("' . $thisEltId . '"));';

if (! empty($this->dependantFields)) {
foreach ($this->dependantFields as $dependantField) {
$script .= '
Event.observe($("' . $dependantField . '"), "change", function() {
toggleValueElements($("' . $thisEltId . '_inherit"), $("' . $thisEltId . '"));
});';
Event.observe($("' . $dependantField . '"), "change", function() {
toggleValueElements($("' . $thisEltId . '_inherit"), $("' . $thisEltId . '"));
});
';
}
}

$script .= '});
});
</script>
';
});
</script>';
}

return '<div id="' . $thisEltId . '">' . parent::_toHtml() . "\n$script" . '</div>';
return $script;
}


/**
* Render HTML block.
*
* @return string
*/
protected function _toHtml()
{
return '<div id="' . $this->getElement()->getId() . '" style="max-width: 500px;">'
. parent::_toHtml() . "\n" . $this->renderScript() . '</div>';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?php
/**
* Copyright © Lyra Network.
* This file is part of PayZen plugin for Magento 2. See COPYING.md for license details.
*
* @author Lyra Network (https://www.lyra.com/)
* @copyright Lyra Network
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Franfinance;

/**
* Custom renderer for the FranFinance payment options field.
*/
class FranfinancePaymentOptions extends \Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\FieldArray\ConfigFieldArray
{
/**
* Prepare to render.
*
* @return void
*/
public function _prepareToRender()
{
$this->addColumn(
'label',
[
'label' => __('Label'),
'style' => 'width: 220px;',
]
);
$this->addColumn(
'payment_means',
[
'label' => __('Count'),
'style' => 'width: 70px;',
'renderer' => $this->getListRenderer('payment_means', $this->getPaymentMeans())
]
);
$this->addColumn(
'fees',
[
'label' => __('Fees'),
'style' => 'width: 120px;',
'renderer' => $this->getListRenderer('fees', $this->getFeeOptions())
]
);
$this->addColumn(
'amount_min',
[
'label' => __('Min. amount'),
'style' => 'width: 100px;'
]
);
$this->addColumn(
'amount_max',
[
'label' => __('Max. amount'),
'style' => 'width: 100px;'
]
);

parent::_prepareToRender();
}

public function getPaymentMeans()
{
/** @var array[string][string] $options */
$options = [
'FRANFINANCE_3X' => '3x',
'FRANFINANCE_4X' => '4x'
];

return $options;
}

public function getFeeOptions()
{
/** @var array[string][string] $options */
$options = [
'0' => __('Without fees'),
'1' => __('With fees')
];

return $options;
}

/**
* Obtain existing data from form element.
*
* Each row will be instance of Varien_Object
*
* @return array
*/
public function getArrayRows()
{
/** @var array[string][array] $defaultOptions */
$defaultOptions = [
'FRANFINANCE_3X' => [
'label' => sprintf(__('Payment in %s times'), '3'),
'amount_max' => '3000'
],
'FRANFINANCE_4X' => [
'label' => sprintf(__('Payment in %s times'), '4'),
'amount_max' => '4000'
]
];

$savedOptions = $this->getElement()->getValue();
if (! is_array($savedOptions)) {
$savedOptions = [];
}

foreach ($savedOptions as $code => $option) {
if (key_exists($code, $defaultOptions)) {
unset($defaultOptions[$code]);
}
}

// Add not saved yet options.
foreach ($defaultOptions as $code => $defaultOption) {
$option = [
'label' => $defaultOption['label'],
'payment_means' => $code,
'fees' => '0',
'amount_min' => '100',
'amount_max' => $defaultOption['amount_max'],
];

$savedOptions[$code] = $option;
}

$this->getElement()->setValue($savedOptions);
return parent::getArrayRows();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
* @copyright Lyra Network
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
namespace Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Fullcb;

/**
* Custom renderer for the Full CB customer group options field.
*/

namespace Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\Fullcb;

class FullcbCustgroupOptions extends \Lyranetwork\Payzen\Block\Adminhtml\System\Config\Form\Field\CustgroupOptions
{
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function _prepareToRender()
/**
* Obtain existing data from form element.
*
* Each row will be instance of Varien_Object
* Each row will be instance of Varien_Object.
*
* @return array
*/
Expand Down
2 changes: 0 additions & 2 deletions Block/Adminhtml/System/Config/Form/Field/Logo.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
class Logo extends \Magento\Config\Block\System\Config\Form\Field
{
/**
*
* @var \Lyranetwork\Payzen\Helper\Data
*/
protected $dataHelper;

/**
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Lyranetwork\Payzen\Helper\Data $dataHelper
* @param array $data
Expand Down
Loading

0 comments on commit 24ba510

Please sign in to comment.