protected function processCommand(AggregateRootTypeCommandInterface $command, array $custom_event_state = [])
    {
        $event_class = $command->getEventClass();
        $default_event_state = [
            'metadata' => $command->getMetadata(),
            'uuid' => $command->getUuid(),
            'seq_number' => $this->getRevision() + 1,
            'aggregate_root_type' => $command->getAggregateRootType()
        ];

        if ($command instanceof AggregateRootCommandInterface) {
            $default_event_state['aggregate_root_identifier'] = $command->getAggregateRootIdentifier();
        } elseif (!isset($custom_event_state['aggregate_root_identifier'])) {
            throw new MissingIdentifierError(
                'Missing required "aggregate_root_identifier" attribute for building domain-event.'
            );
        }
        $embedded_entity_events = new EmbeddedEntityEventList();
        foreach ($command->getEmbeddedEntityCommands() as $embedded_command) {
            $embedded_entity_events->push($this->processEmbeddedEntityCommand($embedded_command));
        }
        $default_event_state['embedded_entity_events'] = $embedded_entity_events;

        return new $event_class(array_merge($custom_event_state, $default_event_state));
    }