-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename ExchangeRate into ExchangeRateLive
- Loading branch information
Showing
65 changed files
with
490 additions
and
461 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...xchange_rate/edycja_kursu_wymiany.feature → ...ge_rate_live/edycja_kursu_wymiany.feature
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
2 changes: 1 addition & 1 deletion
2
...ange_rate/tworzenie_kursu_wymiany.feature → ...rate_live/tworzenie_kursu_wymiany.feature
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
2 changes: 1 addition & 1 deletion
2
...hange_rate/usuwanie_kursu_wymiany.feature → ..._rate_live/usuwanie_kursu_wymiany.feature
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
2 changes: 1 addition & 1 deletion
2
...e_rate/wyświetlanie_kursu_wymiany.feature → ...e_live/wyświetlanie_kursu_wymiany.feature
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
10 changes: 5 additions & 5 deletions
10
fixtures/api/exchange_rates.yaml → fixtures/api/exchange_rate_lives.yaml
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
include: | ||
- 'assets.yaml' | ||
|
||
Panda\Exchange\Domain\Model\ExchangeRate: | ||
exchange_rate_acme_1: | ||
Panda\Exchange\Domain\Model\ExchangeRateLive: | ||
exchange_rate_live_acme_1: | ||
__construct: ['@asset_acme->ticker', '@asset_1->ticker', '<randomFloat(2, 0, 3)>'] | ||
createdAt: <(new DateTimeImmutable())> | ||
updatedAt: <(new DateTimeImmutable())> | ||
exchange_rate_acme_2: | ||
exchange_rate_live_acme_2: | ||
__construct: ['@asset_acme->ticker', '@asset_2->ticker', '<randomFloat(2, 0, 3)>'] | ||
createdAt: <(new DateTimeImmutable())> | ||
updatedAt: <(new DateTimeImmutable())> | ||
exchange_rate_acme_3: | ||
exchange_rate_live_acme_3: | ||
__construct: ['@asset_acme->ticker', '@asset_3->ticker', '<randomFloat(2, 0, 3)>'] | ||
createdAt: <(new DateTimeImmutable())> | ||
updatedAt: <(new DateTimeImmutable())> | ||
exchange_rate_acme_4: | ||
exchange_rate_live_acme_4: | ||
__construct: ['@asset_acme->ticker', '@asset_4->ticker', '<randomFloat(2, 0, 3)>'] | ||
createdAt: <(new DateTimeImmutable())> | ||
updatedAt: <(new DateTimeImmutable())> |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20230723222438 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Rename ExchangeRate into ExchangeRateLive'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE panda_exchange_rate RENAME TO panda_exchange_rate_live'); | ||
$this->addSql('ALTER INDEX uniq_1992c039d58bbb05589c0d1c RENAME TO UNIQ_B1C1ADC316A390FF447BA6D5'); | ||
|
||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE panda_exchange_rate_live RENAME TO panda_exchange_rate'); | ||
$this->addSql('ALTER INDEX uniq_b1c1adc316a390ff447ba6d5 RENAME TO uniq_1992c039d58bbb05589c0d1c'); | ||
} | ||
} |
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
45 changes: 0 additions & 45 deletions
45
src/Exchange/Application/Command/ExchangeRate/CreateExchangeRateCommandHandler.php
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/Exchange/Application/Command/ExchangeRate/CreateReversedExchangeRateCommand.php
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
src/Exchange/Application/Command/ExchangeRate/DeleteExchangeRateCommandHandler.php
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/Exchange/Application/Command/ExchangeRate/UpdateReversedExchangeRateCommand.php
This file was deleted.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
src/Exchange/Application/Command/ExchangeRateLive/CreateExchangeRateLiveCommandHandler.php
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,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Panda\Exchange\Application\Command\ExchangeRateLive; | ||
|
||
use ApiPlatform\Validator\ValidatorInterface; | ||
use Panda\Core\Application\Command\CommandHandlerInterface; | ||
use Panda\Core\Application\Event\EventBusInterface; | ||
use Panda\Exchange\Domain\Event\ExchangeRateLiveCreatedEvent; | ||
use Panda\Exchange\Domain\Event\ReversedExchangeLiveRateCreatedEvent; | ||
use Panda\Exchange\Domain\Factory\ExchangeRateLiveFactoryInterface; | ||
use Panda\Exchange\Domain\Model\ExchangeRateLiveInterface; | ||
use Panda\Exchange\Domain\Repository\ExchangeRateLiveRepositoryInterface; | ||
|
||
final readonly class CreateExchangeRateLiveCommandHandler implements CommandHandlerInterface | ||
{ | ||
public function __construct( | ||
private ExchangeRateLiveRepositoryInterface $exchangeRateRepository, | ||
private ExchangeRateLiveFactoryInterface $exchangeRateFactory, | ||
private EventBusInterface $eventBus, | ||
private ValidatorInterface $validator, | ||
) { | ||
} | ||
|
||
public function __invoke(CreateExchangeRateLiveCommand|CreateReversedExchangeRateLiveCommand $command): ExchangeRateLiveInterface | ||
{ | ||
$exchangeRate = $this->exchangeRateFactory->create($command->baseTicker, $command->quoteTicker, $command->rate); | ||
|
||
$this->validator->validate($exchangeRate, ['groups' => ['panda:create']]); | ||
|
||
$this->exchangeRateRepository->save($exchangeRate); | ||
|
||
switch (get_class($command)) { | ||
case CreateExchangeRateLiveCommand::class: | ||
$this->eventBus->dispatch(new ExchangeRateLiveCreatedEvent($exchangeRate->getId())); | ||
break; | ||
case CreateReversedExchangeRateLiveCommand::class: | ||
$this->eventBus->dispatch(new ReversedExchangeLiveRateCreatedEvent($exchangeRate->getId())); | ||
break; | ||
} | ||
|
||
return $exchangeRate; | ||
} | ||
} |
Oops, something went wrong.