src/Command/Model/EventSourcedAggregate.php
protected function record(PayloadInterface $payload, array $metaData = null): void
    {
        $domainEventMessage = new DomainEventMessage(
            $payload,
            new PayloadType($payload),
            new DateTime(),
            $this->getIdentifier(),
            $this->getNextVersion(),
            array_replace_recursive(
                $this
                    ->getCommandMessage()
                    ->getMetaData(),
                $metaData
            )
        );

        $this
            ->apply($domainEventMessage)
            ->addDomainEventMessage($domainEventMessage);
    }
protected function record(PayloadInterface $payload, array $metaData = null): void
    {
        $domainEventMessage = new DomainEventMessage(
            $payload,
            new PayloadType($payload),
            new DateTime(),
            $this->getIdentifier(),
            $this->getNextVersion(),
            array_replace_recursive(
                $this
                    ->getCommandMessage()
                    ->getMetaData(),
                $metaData
            )
        );

        $this
            ->apply($domainEventMessage)
            ->addDomainEventMessage($domainEventMessage);
    }
Record payload and meta data into a new domain event message.

Meta data from the command message will be recursively replaced with given meta data and added to the domain
event message.

@param PayloadInterface $payload
@param array|null       $metaData
@throws MethodNotFound