/** * @param StoryId $storyId * @param \Prooph\Done\Shared\StoryName $storyName * @return StoryWasStarted */ public static function withStoryIdAndName(StoryId $storyId, StoryName $storyName) { $self = self::occur($storyId->toString(), ['story_name' => $storyName->toString()]); $self->storyId = $storyId; $self->storyName = $storyName; return $self; }
/** * @param StoryName $storyName * @param StoryTeller $storyTeller * @throws \Prooph\Done\Shared\Exception\StoryTeller */ public function registerStoryTeller(StoryName $storyName, StoryTeller $storyTeller) { if (isset($this->storyTellers[$storyName->toString()])) { throw Exception\StoryTeller::alreadyRegisteredForStoryName($storyName); } $this->storyTellers[$storyName->toString()] = $storyTeller; }
/** * @param StoryName $storyName * @param ChapterNumber $chapterNumber * @param Message $previousMessage * @return Message */ public function startChapter(StoryName $storyName, ChapterNumber $chapterNumber, Message $previousMessage) { $command = $this->chapterCommandTemplate->createMessageFromPreviousMessage($previousMessage); $command = $command->withAddedMetadata(Metadata::STORY_CHAPTER, $chapterNumber->toString()); return $command->withAddedMetadata(Metadata::STORY_NAME, $storyName->toString()); }
/** * @param \Prooph\Done\Story\ChapterName $chapterName * @param StoryName $storyName * @return ChapterName */ public static function isDuplicateForStory(\Prooph\Done\Story\ChapterName $chapterName, StoryName $storyName) { return new self(sprintf('Duplicate Chapter name %s for story %s detected', $chapterName->toString(), $storyName->toString())); }
/** * @param ChapterName $chapterName * @param StoryName $storyName * @return Story */ public static function cannotFindMatchingTemplateForChapterName(ChapterName $chapterName, StoryName $storyName) { return new self(sprintf('Story %s cannot find matching template for chapter name %s', $storyName->toString(), $chapterName->toString())); }