/** * @return StoryId */ public function storyId() { if (null === $this->storyId) { $this->storyId = StoryId::fromString($this->aggregateId()); } return $this->storyId; }
/** * @param StoryName $storyName * @param Message $startMessage * @param ChapterTemplate[] $chapterTemplates * @param MessageConverter $messageConverter * @throws Exception\Story * @return Story */ public static function start(StoryName $storyName, Message $startMessage, array $chapterTemplates, MessageConverter $messageConverter) { self::assertChapterTemplates($chapterTemplates, $storyName); $storyId = StoryId::fromString($startMessage->uuid()->toString()); $self = new self(); $self->recordThat(StoryWasStarted::withStoryIdAndName($storyId, $storyName)); $nextCommands = $self->startNextChapters($storyName, $startMessage, $chapterTemplates, $storyId, $messageConverter); if (empty($nextCommands)) { throw Exception\Story::cannotBeStartedForMessage($startMessage); } $self->nextCommands = $nextCommands; return $self; }