-
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.
Chat feature and CQRS - messegnger Initialized
- Loading branch information
Showing
141 changed files
with
5,712 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# VehicleStatus: | ||
# type: enum | ||
# config: | ||
# enumClass: App\Entity\Transport\Vehicle\VehicleStatus | ||
# # values: | ||
# # GREEN: | ||
# # description: "The color green" | ||
|
||
UploadFile: | ||
type: custom-scalar | ||
config: | ||
scalarType: '@=newObject("Overblog\\GraphQLBundle\\Upload\\Type\\GraphQLUploadType")' |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230930081522 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('CREATE TABLE shipment_order_shipment_document (shipment_order_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', shipment_document_id BINARY(16) NOT NULL COMMENT \'(DC2Type:ulid)\', INDEX IDX_4D2269C72BC89259 (shipment_order_id), INDEX IDX_4D2269C7EC01E0A3 (shipment_document_id), PRIMARY KEY(shipment_order_id, shipment_document_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE shipment_order_shipment_document ADD CONSTRAINT FK_4D2269C72BC89259 FOREIGN KEY (shipment_order_id) REFERENCES shipment_order (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE shipment_order_shipment_document ADD CONSTRAINT FK_4D2269C7EC01E0A3 FOREIGN KEY (shipment_document_id) REFERENCES shipment_document (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE shipment_document ADD meta LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', ADD type VARCHAR(32) NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE shipment_order_shipment_document DROP FOREIGN KEY FK_4D2269C72BC89259'); | ||
$this->addSql('ALTER TABLE shipment_order_shipment_document DROP FOREIGN KEY FK_4D2269C7EC01E0A3'); | ||
$this->addSql('DROP TABLE shipment_order_shipment_document'); | ||
$this->addSql('ALTER TABLE shipment_document DROP meta, DROP type'); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
final class Version20230930084905 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return ''; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE shipment_document_attachment CHANGE src src VARCHAR(225) NOT NULL'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->addSql('ALTER TABLE shipment_document_attachment CHANGE src src VARCHAR(64) NOT NULL'); | ||
} | ||
} |
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,6 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
|
||
interface EntityCreationCommandInterface extends EntityMutationCommandInterface{ | ||
|
||
} |
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,24 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
use Symfony\Component\Uid\Ulid; | ||
|
||
|
||
|
||
/** | ||
* @deprecated 0.0.0 | ||
*/ | ||
trait EntityCreationCommandTrait{ | ||
private ?Ulid $uid = null; | ||
|
||
|
||
public function getUid(): ?Ulid{ | ||
return $this->uid; | ||
} | ||
|
||
public function setUid(?Ulid $uid): static{ | ||
$this->uid = $uid; | ||
return $this; | ||
} | ||
|
||
|
||
} |
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,11 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
use App\CQRS\MessageInterface; | ||
use Symfony\Component\Uid\Ulid; | ||
|
||
interface EntityMutationCommandInterface extends MessageInterface{ | ||
|
||
public function getUid(): ?Ulid; | ||
|
||
public function setUid(?Ulid $uid): static; | ||
} |
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,21 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
use Symfony\Component\Uid\Ulid; | ||
|
||
|
||
|
||
trait EntityMutationCommandTrait{ | ||
private ?Ulid $uid = null; | ||
|
||
|
||
public function getUid(): ?Ulid{ | ||
return $this->uid; | ||
} | ||
|
||
public function setUid(?Ulid $uid): static{ | ||
$this->uid = $uid; | ||
return $this; | ||
} | ||
|
||
|
||
} |
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,6 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
|
||
interface EntityUpdateCommandInterface extends EntityMutationCommandInterface{ | ||
|
||
} |
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,36 @@ | ||
<?php | ||
namespace App\CQRS\Command; | ||
use App\CQRS\Command\Result\CQRSEntityMutationResult; | ||
use App\CQRS\Command\Result\CQRSEntryCreationCommandResult; | ||
use App\CQRS\Command\Result\CQRSEntryUpdateCommandResult; | ||
use App\CQRS\CommandBusInterface; | ||
use Symfony\Component\Uid\Ulid; | ||
class MutationCommandContext{ | ||
|
||
|
||
private ?CQRSEntityMutationResult $result = null; | ||
|
||
public function __construct(private CommandBusInterface $commandBus, private ?string $clientMuationId = null){ | ||
|
||
} | ||
|
||
|
||
public function dispatch(EntityMutationCommandInterface $command, array $stamps = []): CQRSEntityMutationResult{ | ||
|
||
if(!($uid = $command->getUid())){ | ||
$uid = new Ulid(); | ||
$command->setUid($uid); | ||
} | ||
|
||
$this->commandBus->dispatch($command, $stamps); | ||
|
||
return $this->result ??= ( | ||
($command instanceof EntityCreationCommandInterface) ? | ||
new CQRSEntryCreationCommandResult($uid, $this->clientMuationId) | ||
: | ||
new CQRSEntryUpdateCommandResult($uid, $this->clientMuationId) | ||
); | ||
|
||
} | ||
|
||
} |
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,22 @@ | ||
<?php | ||
namespace App\CQRS\Command\Result; | ||
use Overblog\GraphQLBundle\Annotation\Field; | ||
use Overblog\GraphQLBundle\Annotation\Type; | ||
|
||
|
||
#[Type] | ||
class CQRSCommandResult{ | ||
|
||
#[Field()] | ||
private ?string $clientMutationId; | ||
|
||
|
||
public function __construct(?string $clientMutationId){ | ||
$this->clientMutationId = $clientMutationId; | ||
} | ||
|
||
public function getClientMutationId(): ?string{ | ||
return $this->clientMutationId; | ||
} | ||
|
||
} |
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,32 @@ | ||
<?php | ||
namespace App\CQRS\Command\Result; | ||
|
||
use Overblog\GraphQLBundle\Annotation\Deprecated; | ||
use Overblog\GraphQLBundle\Annotation\Field; | ||
use Overblog\GraphQLBundle\Annotation\Type; | ||
use Symfony\Component\Uid\Ulid; | ||
|
||
#[Type()] | ||
class CQRSEntityMutationResult extends CQRSCommandResult{ | ||
|
||
|
||
#[Field(type: 'Ulid')] | ||
#[Deprecated("use id instead")] | ||
private ?Ulid $uid = null; | ||
|
||
public function __construct(Ulid $uid, ?string $clientMutationId = null){ | ||
$this->uid = $uid; | ||
parent::__construct($clientMutationId); | ||
} | ||
|
||
|
||
public function getUid(): ?Ulid{ | ||
return $this->uid; | ||
} | ||
|
||
#[Field(name: 'id', type: 'Ulid')] | ||
public function getId(): ?Ulid{ | ||
return $this->getUid(); | ||
} | ||
|
||
} |
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,9 @@ | ||
<?php | ||
namespace App\CQRS\Command\Result; | ||
use Overblog\GraphQLBundle\Annotation\Type; | ||
|
||
|
||
#[Type()] | ||
class CQRSEntryCreationCommandResult extends CQRSEntityMutationResult{ | ||
|
||
} |
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,9 @@ | ||
<?php | ||
namespace App\CQRS\Command\Result; | ||
use Overblog\GraphQLBundle\Annotation\Type; | ||
|
||
|
||
#[Type()] | ||
class CQRSEntryUpdateCommandResult extends CQRSEntityMutationResult{ | ||
|
||
} |
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,62 @@ | ||
<?php | ||
namespace App\CQRS; | ||
|
||
use App\CQRS\Command\MutationCommandContext; | ||
use App\CQRS\Command\Result\CQRSEntryCreationCommandResult; | ||
use Symfony\Component\Messenger\MessageBusInterface as BaseMessageBusInterface; | ||
use Symfony\Component\Uid\Factory\UlidFactory; | ||
|
||
class CommandBus extends MessageBus implements CommandBusInterface{ | ||
|
||
|
||
/** | ||
* @var array<string,CQRSEntryCreationCommandResult> | ||
*/ | ||
private array $results = []; | ||
|
||
|
||
/** | ||
* @var array<string,MutationCommandContext> | ||
*/ | ||
private array $mutationContexts = []; | ||
|
||
|
||
public function __construct(private BaseMessageBusInterface $commandBus,private UlidFactory $ulidFactory) { | ||
parent::__construct($commandBus); | ||
} | ||
|
||
public function getMutationContext(?string $clientMutationId = null): MutationCommandContext{ | ||
|
||
if( is_string($clientMutationId) && array_key_exists($clientMutationId,$this->mutationContexts)){ | ||
return $this->mutationContexts[$clientMutationId]; | ||
} | ||
|
||
$context = new MutationCommandContext($this, $clientMutationId); | ||
|
||
if(is_string($clientMutationId)) | ||
return $this->mutationContexts[$clientMutationId] = $context; | ||
|
||
return $context; | ||
} | ||
|
||
public function dispatchContextual(EntityCreationCommandInterface $command, ?string $clientMuationId): CQRSEntryCreationCommandResult{ | ||
return $this->getMutationContext($clientMuationId)->dispatch($command); | ||
} | ||
|
||
|
||
// public function getOptimisticEntryCreationResult(?string $clientMutationId = null): CQRSEntryCreationCommandResult{ | ||
|
||
// if( is_string($clientMutationId) && array_key_exists($clientMutationId,$this->results)){ | ||
// return $this->results[$clientMutationId]; | ||
// } | ||
|
||
// $ulid = $this->ulidFactory->create(); | ||
// $result = new CQRSEntryCreationCommandResult($ulid); | ||
|
||
// if(is_string($clientMutationId)) | ||
// return $this->results[$clientMutationId] = $result; | ||
|
||
// return $result; | ||
// } | ||
|
||
} |
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,11 @@ | ||
<?php | ||
namespace App\CQRS; | ||
use App\CQRS\Command\MutationCommandContext; | ||
// use App\CQRS\Command\Result\CQRSEntryCreationCommandResult; | ||
|
||
|
||
interface CommandBusInterface extends MessageBusInterface{ | ||
|
||
public function getMutationContext(?string $clientMutationId = null): MutationCommandContext; | ||
// public function getOptimisticEntryCreationResult(?string $clientMutationId = null): CQRSEntryCreationCommandResult; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/CQRS/Composition/InitiatingUserAwareMessageInterface.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,14 @@ | ||
<?php | ||
namespace App\CQRS\Composition; | ||
use App\CQRS\Query\QueryInterface; | ||
use Symfony\Component\Uid\Ulid; | ||
|
||
|
||
interface InitiatingUserAwareMessageInterface extends QueryInterface{ | ||
|
||
/** | ||
* The Id of the user Initialting this Message | ||
* @return Ulid | ||
*/ | ||
public function getInitiatingUserId(): ?Ulid; | ||
} |
Oops, something went wrong.