/** * Transforms a string (number) to an object (issue). * * @param VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment $issueCommentEntity * * @return array|null * * @throws TransformationFailedException if object (issue) is not found */ public function reverseTransform($issueCommentEntity) { if ($issueCommentEntity === null) { // causes a validation error throw new TransformationFailedException('issueCommentEntity is null'); } $issueComment = array('body' => $issueCommentEntity->getComment()); return $issueComment; }
/** * Transforms an issue array into an issue Entity object. * * @param \VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment|null $issueComment * * @return string */ public function transform($issueComment) { if (null === $issueComment) { return null; } $issueCommentEntity = new IssueComment(); $issueCommentEntity->setId($issueComment['id']); $issueCommentEntity->setComment($issueComment['body']); $issueCommentEntity->setCreatedAt($this->formatDate($issueComment['created_at'])); if (isset($issueComment['updated_at'])) { $issueCommentEntity->setUpdatedAt($this->formatDate($issueComment['updated_at'])); } if (isset($issueComment['author']) && is_array($issueComment['author'])) { $user = $this->userTransformer->transform($issueComment['author']); $issueCommentEntity->setUser($user); } return $issueCommentEntity; }
/** * Creates a New issue Comment on github. * * @param \VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment $issueCommentEntity */ public function createIssueComment(\VersionControl\GitlabIssueBundle\Entity\Issues\IssueComment $issueCommentEntity) { $this->authenticate(); $issueId = $issueCommentEntity->getIssue()->getId(); $comment = $this->client->api('issues')->addComment($this->issueIntegrator->getProjectName(), $issueId, $issueCommentEntity->getComment()); $issueCommentTransfomer = new IssueCommentToEntityTransformer(); return $issueCommentTransfomer->transform($comment); }