src/Model/Aggregate/AggregateRoot.php
public function create(CreateAggregateRootCommand $create_command, StateMachineInterface $state_machine)
    {
        $initial_data = $this->createInitialData($create_command, $state_machine);

        $created_event = $this->processCommand(
            $create_command,
            [ 'aggregate_root_identifier' => $initial_data['identifier'], 'data' => $initial_data ]
        );

        if (!$created_event instanceof AggregateRootCreatedEvent) {
            throw new UnsupportedEventTypeError(
                sprintf(
                    'Corrupt event type detected. Events that reflect entity creation must descend from %s.',
                    AggregateRootCreatedEvent::CLASS
                )
            );
        }

        $this->applyEvent($created_event);
    }
public function create(CreateAggregateRootCommand $create_command, StateMachineInterface $state_machine)
    {
        $initial_data = $this->createInitialData($create_command, $state_machine);

        $created_event = $this->processCommand(
            $create_command,
            [ 'aggregate_root_identifier' => $initial_data['identifier'], 'data' => $initial_data ]
        );

        if (!$created_event instanceof AggregateRootCreatedEvent) {
            throw new UnsupportedEventTypeError(
                sprintf(
                    'Corrupt event type detected. Events that reflect entity creation must descend from %s.',
                    AggregateRootCreatedEvent::CLASS
                )
            );
        }

        $this->applyEvent($created_event);
    }
public function create ( CreateAggregateRootCommand $ create_command , StateMachineInterface $ state_machine ) { $ initial_data = $ this -> createInitialData ( $ create_command , $ state_machine ) ; $ created_event = $ this -> processCommand ( $ create_command , [ 'aggregate_root_identifier' => $ initial_data [ 'identifier' ] , 'data' => $ initial_data ] ) ; if ( ! $ created_event instanceof AggregateRootCreatedEvent ) { throw new UnsupportedEventTypeError ( sprintf ( 'Corrupt event type detected. Events that reflect entity creation must descend from %s.' , AggregateRootCreatedEvent :: CLASS ) ) ; } $ this -> applyEvent ( $ created_event ) ; }
Start a new life-cycle for the current aggregate-root.

@param CreateAggregateRootCommand $create_command
@param StateMachineInterface $state_machine
Start a new life - cycle for the current aggregate - root .