-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e4b77e
commit b458422
Showing
6 changed files
with
98 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,5 +54,5 @@ | |
"wallee/sdk": "3.0.1" | ||
}, | ||
"type": "shopware-platform-plugin", | ||
"version": "4.0.8" | ||
"version": "4.0.9" | ||
} |
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,89 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace WalleePayment\Migration; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Shopware\Core\Framework\Migration\MigrationStep; | ||
use Shopware\Core\Framework\Uuid\Uuid; | ||
use Shopware\Core\System\StateMachine\Aggregation\StateMachineState\StateMachineStateDefinition; | ||
use Shopware\Core\System\StateMachine\Aggregation\StateMachineTransition\StateMachineTransitionDefinition; | ||
use Shopware\Core\System\StateMachine\StateMachineDefinition; | ||
|
||
/** | ||
* Class Migration1605701049StateMachineEntity | ||
* | ||
* @package WalleePayment\Migration | ||
*/ | ||
class Migration1605701049StateMachineEntity extends MigrationStep | ||
{ | ||
|
||
/** | ||
* get creation timestamp | ||
* | ||
* @return int | ||
*/ | ||
public function getCreationTimestamp(): int | ||
{ | ||
return 1605701049; | ||
} | ||
|
||
/** | ||
* update non-destructive changes | ||
* | ||
* @param \Doctrine\DBAL\Connection $connection | ||
*/ | ||
public function update(Connection $connection): void | ||
{ | ||
try { | ||
// Enable mark transaction as paid when it's on status reminded | ||
$table = StateMachineDefinition::ENTITY_NAME; | ||
$stateMachineId = $connection->fetchColumn( | ||
"SELECT id FROM `$table` WHERE `technical_name` = :technical_name", | ||
[ | ||
'technical_name' => 'order_transaction.state', | ||
] | ||
); | ||
|
||
$table = StateMachineStateDefinition::ENTITY_NAME; | ||
$remindedStateId = $connection->fetchColumn( | ||
"SELECT id FROM `$table` WHERE `technical_name` = :technical_name AND `state_machine_id` = :state_machine_id", | ||
[ | ||
'technical_name' => 'reminded', | ||
'state_machine_id' => $stateMachineId, | ||
] | ||
); | ||
|
||
$paidStateId = $connection->fetchColumn( | ||
"SELECT id FROM `$table` WHERE `technical_name` = :technical_name AND `state_machine_id` = :state_machine_id", | ||
[ | ||
'technical_name' => 'paid', | ||
'state_machine_id' => $stateMachineId, | ||
] | ||
); | ||
|
||
$id = Uuid::randomBytes(); | ||
$connection->insert(StateMachineTransitionDefinition::ENTITY_NAME, | ||
[ | ||
'id' => $id, | ||
'action_name' => 'paid', | ||
'state_machine_id' => $stateMachineId, | ||
'from_state_id' => $remindedStateId, | ||
'to_state_id' => $paidStateId, | ||
'created_at' => date('Y-m-d H:i:s') | ||
] | ||
); | ||
} catch (\Exception $exception) { | ||
// column probably exists | ||
} | ||
} | ||
|
||
/** | ||
* update destructive changes | ||
* | ||
* @param \Doctrine\DBAL\Connection $connection | ||
*/ | ||
public function updateDestructive(Connection $connection): void | ||
{ | ||
// implement update destructive | ||
} | ||
} |