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)]); }