private function createPostFromParameters(CreatePostParameters $createPostParameters) : Post { $postType = $this->postTypeFactory->createPostTypeByIntCode($createPostParameters->getPostTypeCode()); $collection = $this->collectionService->getCollectionById($createPostParameters->getCollectionId()); $profile = $this->profileService->getProfileById($createPostParameters->getProfileId()); $post = new Post($postType, $profile, $collection, $createPostParameters->getContent()); $post->setAttachmentIds($createPostParameters->getAttachmentIds()); $post->setThemeIds($collection->getThemeIds()); $this->postRepository->createPost($post); return $post; }
public function format(Post $post) : array { $postTypeObject = $this->postTypeFactory->createPostTypeByIntCode($post->getPostTypeCode()); return array_merge_recursive($post->toJSON(), ['post_type' => $postTypeObject->toJSON(), 'profile' => $this->profileService->getProfileById($post->getAuthorProfile()->getId())->toJSON(), 'attachments' => $this->formatAttachments($post)]); }