Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public function detectContentTypeOfPost(Post $post) : string
 {
     if (count($post->getAttachmentIds())) {
         $attachment = $this->attachmentService->getById($post->getAttachmentIds()[0]);
         switch ($resource = $attachment->getMetadata()['resource']) {
             default:
                 throw new \Exception(sprintf('Unknown resource `%s`', $resource));
             case YoutubeLinkMetadata::RESOURCE_TYPE:
                 return ContentTypeCriteria::CONTENT_TYPE_VIDEO;
             case PageLinkMetadata::RESOURCE_TYPE:
                 return ContentTypeCriteria::CONTENT_TYPE_LINK;
             case ImageLinkMetadata::RESOURCE_TYPE:
                 return ContentTypeCriteria::CONTENT_TYPE_IMAGE;
             case WebmLinkMetadata::RESOURCE_TYPE:
                 return ContentTypeCriteria::CONTENT_TYPE_VIDEO;
             case UnknownLinkMetadata::RESOURCE_TYPE:
                 return ContentTypeCriteria::CONTENT_TYPE_TEXT;
         }
     } else {
         return ContentTypeCriteria::CONTENT_TYPE_TEXT;
     }
 }
Ejemplo n.º 3
0
 private function formatAttachments(Post $post) : array
 {
     return array_map(function (Attachment $attachment) {
         return $this->attachmentFormatter->format($attachment);
     }, $this->attachmentService->getManyByIds($post->getAttachmentIds()));
 }
Ejemplo n.º 4
0
 protected function getSource(Post $entity) : Source
 {
     return $source = $this->sourceFactory->getCollectionSource($entity->getCollection()->getId());
 }
 protected function isIndexable(Post $entity) : bool
 {
     return $entity->getPostTypeCode() === DiscussionPostType::CODE_INT;
 }
Ejemplo n.º 6
0
 protected function getThemeIdsWeight(Post $entity) : array
 {
     return $this->themeWeightCalculator->calculateWeights($entity->getThemeIds());
 }
Ejemplo n.º 7
0
 protected function isIndexable(Post $entity) : bool
 {
     return $entity->getCollection()->isCommunityCollection();
 }
Ejemplo n.º 8
0
 protected function isIndexable(Post $entity) : bool
 {
     return $entity->getCollection()->isProfileCollection();
 }