for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright (c) 2017 Constantin Galbenu <[email protected]>
*/
namespace Gica\Cqrs\Event\MetadataFactory;
use Gica\Cqrs\Command\CommandDispatcher\AuthenticatedIdentityReaderService;
use Gica\Cqrs\Command\CommandWithMetadata;
use Gica\Cqrs\Event\MetaData;
use Gica\Cqrs\Event\MetadataFactory;
class DefaultMetadataFactory implements MetadataFactory
{
* @var AuthenticatedIdentityReaderService
private $identityReaderService;
public function __construct(
?AuthenticatedIdentityReaderService $identityReaderService = null
)
$this->identityReaderService = $identityReaderService;
}
public function factoryEventMetadata(CommandWithMetadata $command, $aggregate): MetaData
return new MetaData(
$command->getCommand()->getAggregateId(),
get_class($aggregate),
new \DateTimeImmutable(),
$this->identityReaderService ? $this->identityReaderService->getAuthenticatedIdentityId() : null,
$command->getMetadata()
);