Skip to content

AggregateChanged

Something that happened in the past and that is of importance to the business.


Constants

Constant Visibility Type Value
DATE_FORMAT public 'Y-m-d H:i:s.u'

Properties

payload

public array|null $payload

metadata

protected array|null $metadata

recordedAt

protected ?\DateTimeInterface $recordedAt

Methods

__construct

final private __construct(\Codefy\Domain\Aggregate\AggregateId $aggregateId, array|null $payload, array|null $metadata = []): mixed
  • This method is final. Parameters:
Parameter Type Description
$aggregateId \Codefy\Domain\Aggregate\AggregateId
$payload array|null
$metadata array|null

occur

Named constructor for generating a domain event.

final public static occur(\Codefy\Domain\Aggregate\AggregateId $aggregateId, array $payload, array $metadata = []): static
  • This method is static. This method is final. Parameters:*
Parameter Type Description
$aggregateId \Codefy\Domain\Aggregate\AggregateId
$payload array
$metadata array

fromArray

Named constructor for generating a domain event from an array.

final public static fromArray(array $data): \Codefy\Domain\EventSourcing\DomainEvent
  • This method is static. This method is final. Parameters:*
Parameter Type Description
$data array

payload

Returns payload array.

public payload(): array

eventType

Name of the event.

public eventType(): string

aggregateId

The ID of the Aggregate this event belongs to.

public aggregateId(): \Codefy\Domain\Aggregate\AggregateId

eventId

Uuid of the event.

public eventId(): \Codefy\Domain\EventSourcing\EventId

metadata

Event metadata.

public metadata(): array

playhead

Version of the recorded event.

public playhead(): int

recordedAt

Date the event was recorded on.

public recordedAt(): ?\DateTimeInterface

toArray

Returns array of event data.

public toArray(): array<string,mixed>

param

Retrieve data from payload by name.

public param(string $name, mixed $default = null): mixed

Parameters:

Parameter Type Description
$name string
$default mixed

metaParam

Retrieve meta data from metadata by name.

public metaParam(string $name, mixed $default = null): mixed

Parameters:

Parameter Type Description
$name string
$default mixed

withMetadata

Append event metadata.

final public withMetadata(array $metadata): self
  • This method is final. Parameters:
Parameter Type Description
$metadata array

withAddedMetadata

Append event metadata.

final public withAddedMetadata(string $key, mixed $value): self
  • This method is final. Parameters:
Parameter Type Description
$key string
$value mixed

withPlayhead

Append event version.

final public withPlayhead(int $playhead): self
  • This method is final. Parameters:
Parameter Type Description
$playhead int

setEventId

private setEventId(\Codefy\Domain\EventSourcing\EventId $eventId): void

Parameters:

Parameter Type Description
$eventId \Codefy\Domain\EventSourcing\EventId

setEventType

private setEventType(string $eventType): void

Parameters:

Parameter Type Description
$eventType string

setAggregateId

private setAggregateId(\Codefy\Domain\Aggregate\AggregateId $aggregateId): void

Parameters:

Parameter Type Description
$aggregateId \Codefy\Domain\Aggregate\AggregateId

setPlayhead

private setPlayhead(int $playhead): void

Parameters:

Parameter Type Description
$playhead int

setPayload

private setPayload(array|null $payload): void

Parameters:

Parameter Type Description
$payload array|null

init

private init(): void