Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions Model/Config/Backend/EmptyToDelete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace Buckaroo\Magento2\Model\Config\Backend;

use Magento\Framework\App\Config\Value;
use Magento\Framework\App\ResourceConnection;

class EmptyToDelete extends Value
{
/**
* @var ResourceConnection
*/
protected $resourceConnection;

/**
* Constructor
*
* @param ResourceConnection $resourceConnection
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
*/
public function __construct(
ResourceConnection $resourceConnection,
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
$this->resourceConnection = $resourceConnection;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}

/**
* Delete row from core_config_data if value is empty
*
* @return $this
*/
public function beforeSave()
{
try {
$value = $this->getValue();

// If the value is empty, delete the row
if (empty($value)) {
$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('core_config_data');

$connection->delete(
$tableName,
[
'path = ?' => $this->getPath(),
'scope = ?' => $this->getScope(),
'scope_id = ?' => $this->getScopeId()
]
);

// Prevent saving an empty value
$this->setValue(null);
}
} catch (\Exception $e) {
$this->_logger->critical($e->getMessage());
}

return parent::beforeSave();
}
}
18 changes: 17 additions & 1 deletion Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,24 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
$this->addCustomerLastPayByBankIssuer($setup);
}

if (version_compare($context->getVersion(), '1.51.0', '<')) {
// Update buckaroo_magento2_mrcash title to 'Bancontact'
$setup->getConnection()->update(
$setup->getTable('core_config_data'),
['value' => 'Bancontact'],
['path = ?' => 'payment/buckaroo_magento2_mrcash/title']
);

// Update buckaroo_magento2_billink title to 'Billink'
$setup->getConnection()->update(
$setup->getTable('core_config_data'),
['value' => 'Billink'],
['path = ?' => 'payment/buckaroo_magento2_billink/title']
);
}

$this->setCustomerIDIN($setup);

$this->setCustomerIsEighteenOrOlder($setup);

$this->setProductIDIN($setup);
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/afterpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_afterpay/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/afterpay2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_afterpay2/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/afterpay20.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_afterpay20/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/alipay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_alipay/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
3 changes: 2 additions & 1 deletion etc/adminhtml/system/payment_methods/applepay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_applepay/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext</label>
<comment><![CDATA[This controls the description which the user sees during checkout.]]></comment>
<config_path>payment/buckaroo_magento2_applepay/subtext</config_path>
</field>

<field id="subtext_style" translate="label comment" type="select" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext style</label>
<comment><![CDATA[Choose a font style for the subtext.]]></comment>
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/belfius.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_belfius/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/billink.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_billink/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/blik.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_blik/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/capayable_in3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_capayablein3/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/capayable_postpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_capayablepostpay/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/creditcards.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_creditcards/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/emandate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_emandate/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/eps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_eps/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
3 changes: 2 additions & 1 deletion etc/adminhtml/system/payment_methods/giftcards.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_giftcards/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext</label>
<comment><![CDATA[This controls the description which the user sees during checkout.]]></comment>
<config_path>payment/buckaroo_magento2_giftcards/subtext</config_path>
</field>

<field id="subtext_style" translate="label comment" type="select" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext style</label>
<comment><![CDATA[Choose a font style for the subtext.]]></comment>
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/ideal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ For precise cost details, please reach out to <a href="mailto:wecare@buckaroo.nl
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_ideal/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/idealprocessing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ For precise cost details, please reach out to <a href="mailto:wecare@buckaroo.nl
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_idealprocessing/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/kbc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_kbc/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/klarna.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_klarna/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/klarnain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_klarnain/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/klarnakp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_klarnakp/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/knaken.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_knaken/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/mbway.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_mbway/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/mrcash.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_mrcash/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/multibanco.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_multibanco/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/p24.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_p24/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
3 changes: 2 additions & 1 deletion etc/adminhtml/system/payment_methods/paybybank.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_paybybank/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext</label>
<comment><![CDATA[This controls the description which the user sees during checkout.]]></comment>
<config_path>payment/buckaroo_magento2_paybybank/subtext</config_path>
</field>

<field id="subtext_style" translate="label comment" type="select" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Frontend subtext style</label>
<comment><![CDATA[Choose a font style for the subtext.]]></comment>
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/payconiq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_payconiq/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/paypal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_paypal/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/payperemail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_payperemail/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/pospayment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_pospayment/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
1 change: 1 addition & 0 deletions etc/adminhtml/system/payment_methods/sepa_direct_debit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<label>Frontend label</label>
<comment><![CDATA[Determines the frontend label shown.]]></comment>
<config_path>payment/buckaroo_magento2_sepadirectdebit/title</config_path>
<backend_model>Buckaroo\Magento2\Model\Config\Backend\EmptyToDelete</backend_model>
</field>

<field id="subtext" translate="label comment" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
Loading
Loading