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 $payload

metadata

protected ?array $metadata

recordedAt

protected ?\DateTimeInterface $recordedAt

Methods

__construct

private __construct(\Codefy\Domain\Aggregate\AggregateId $aggregateId, ?array $payload, ?array $metadata = []): mixed

Parameters:

Parameter Type Description
$aggregateId \Codefy\Domain\Aggregate\AggregateId
$payload ?array
$metadata ?array

occur

Named constructor for generating a domain event.

final public static occur(\Codefy\Domain\Aggregate\AggregateId $aggregateId, array $payload, array $metadata = []): self
  • 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(): string|\Codefy\Domain\EventSourcing\EventId

metadata

Event metadata.

public metadata(): array

playhead

Aggregate version.

public playhead(): int

recordedAt

The date the event occurred on.

public recordedAt(): string|\DateTimeInterface

toArray

Returns array of event data.

public toArray(): array

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 $payload): void

Parameters:

Parameter Type Description
$payload ?array

init

private init(): void


Automatically generated on 2025-10-13