public static function create(AggregateIdInterface $aggregateId, $name) { $aggregate = new static(); $aggregate->recordThat(new AggregateRootCreated($aggregateId, $name)); $aggregate->recordThat(new SomethingDone()); return $aggregate; }
/** * @param TaskListPosition $parentTaskListPosition * @param NodeName $nodeName * @param Task[] $tasks * @param array $config * @param bool $syncLogMessages * @throws \InvalidArgumentException * @return static */ public static function setUpAsSubProcess(TaskListPosition $parentTaskListPosition, NodeName $nodeName, array $tasks, array $config = array(), $syncLogMessages = true) { /** @var $instance Process */ $instance = new static(); $instance->assertConfig($config); $processId = ProcessId::generate(); $taskList = TaskList::scheduleTasks(TaskListId::linkWith($nodeName, $processId), $tasks); if (!is_bool($syncLogMessages)) { throw new \InvalidArgumentException("Argument syncLogMessages must be of type boolean"); } $instance->recordThat(ProcessWasSetUp::asSubProcess($processId, $parentTaskListPosition, $taskList, $config, $syncLogMessages)); return $instance; }
/** * @param UserId $id * @param string $name * @return static */ public static function create(UserId $id, $name) { $user = new static(); $user->recordThat(new UserWasCreated($id, $name)); return $user; }