/** * @param GithubRepo $githubRepo * @param PullRequest $pullRequestValueObject * * @return GithubPullRequest */ public function createFromValueObject(GithubRepo $githubRepo, PullRequest $pullRequestValueObject) { $githubPullRequest = new GithubPullRequest(); $githubPullRequest->setRepo($githubRepo); $githubPullRequest->setNumber($pullRequestValueObject->getNumber()); $githubPullRequest->setTitle($pullRequestValueObject->getTitle()); $githubPullRequest->setBody($pullRequestValueObject->getBody()); $githubPullRequest->setState(GithubPullRequestState::convert($pullRequestValueObject->getState())); $githubPullRequest->setLocked($pullRequestValueObject->isLocked()); $githubPullRequest->setMerged($pullRequestValueObject->isMerged()); $githubPullRequest->setGithubCreatedAt($pullRequestValueObject->getGithubCreatedAt()); $githubPullRequest->setGithubUpdatedAt($pullRequestValueObject->getGithubUpdatedAt()); $this->mapper->map($pullRequestValueObject, $githubPullRequest); return $githubPullRequest; }
/** * @param PullRequestPayload $pullRequestPayload * * @return bool */ public function process(PullRequestPayload $pullRequestPayload) { $repoValueObject = $this->repoFactory->create($pullRequestPayload); $githubRepo = $this->githubRepoFacade->getOrCreate($repoValueObject); $pullRequestValueObject = $this->pullRequestFactory->create($pullRequestPayload); $githubPullRequest = $this->githubPullRequestFacade->getOrCreate($githubRepo, $pullRequestValueObject); $commitValueObject = $this->commitFactory->create($pullRequestPayload); $githubCommit = $this->githubCommitFacade->getOrCreate($githubRepo, $commitValueObject); $pullRequestCreatorValueObject = $this->pullRequestCreatorFactory->create($pullRequestPayload); $githubPullRequestCreator = $this->githubUserFacade->getOrCreate($pullRequestCreatorValueObject); $githubPullRequest->setCreatedBy($githubPullRequestCreator); if (null !== $pullRequestPayload->getPullRequestAssigneeDetails()) { $pullRequestAssigneeValueObject = $this->pullRequestAssigneeFactory->create($pullRequestPayload); $githubPullRequestAssignee = $this->githubUserFacade->getOrCreate($pullRequestAssigneeValueObject); $githubPullRequest->setAssignedTo($githubPullRequestAssignee); } $githubPullRequest->setLastCommit($githubCommit); $githubPullRequest->setState(GithubPullRequestState::convert($pullRequestValueObject->getState())); $this->em->persist($githubPullRequest); $this->em->persist($githubCommit); $this->em->flush(); return true; }