This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to be compatible with new API URLs
- Loading branch information
jmauzyk
committed
Feb 12, 2020
1 parent
abf6fba
commit 3472944
Showing
6 changed files
with
67 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace jmauzyk\commerce\cardconnect\migrations; | ||
|
||
use Craft; | ||
use craft\db\Migration; | ||
use craft\db\Query; | ||
use craft\commerce\Plugin; | ||
use craft\commerce\records\Gateway; | ||
|
||
/** | ||
* m200211_195001_remove_api_port migration. | ||
*/ | ||
class m200211_195001_remove_api_port extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$schemaVersion = Craft::$app->projectConfig->get( | ||
'plugins.commerce-cardconnect.schemaVersion', | ||
true | ||
); | ||
|
||
if (version_compare($schemaVersion, '1.1', '<')) { | ||
$rows = (new Query()) | ||
->from('{{%commerce_gateways}}') | ||
->where(['type' => 'jmauzyk\commerce\cardconnect\gateways\Gateway']) | ||
->all(); | ||
|
||
$service = Plugin::getInstance()->getGateways(); | ||
foreach ($rows as $row) { | ||
$settings = json_decode($row['settings']); | ||
if (isset($settings->apiPort)) { | ||
unset($settings->apiPort); | ||
$this->update('{{%commerce_gateways}}', ['settings' => json_encode($settings)], ['id' => $row['id']]); | ||
$gateway = $service->getGatewayById($row['id']); | ||
$service->saveGateway($gateway); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m200211_195001_remove_api_port cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters