public function subscribeCommunity(Profile $profile, Community $community, $options = null) : Subscribe { $subscribe = new Subscribe(); $subscribe->setProfileId($profile->getId())->setOptions($options)->setSubscribeId($community->getId())->setSubscribeType(Subscribe::TYPE_COMMUNITY); $em = $this->getEntityManager(); $em->persist($subscribe); $em->flush(); return $subscribe; }
public function createProfile(Profile $profile) : Profile { $em = $this->getEntityManager(); if ($profile->isPersisted()) { throw new \Exception('Attempt to recreate profile entity'); } $em->persist($profile); $em->flush($profile); return $profile; }
protected function getThemeIdsWeight(Profile $entity) : array { return $this->themeWeightCalculator->calculateWeights($entity->getInterestingInIds()); }
public function getLetter() : string { return substr($this->profile->getGreetings()->__toString(), 0, 1); }
public function listSubscribedCommunities(Profile $profile, Seek $seek) : array { return $this->subscribeRepository->findBy(['profileId' => $profile->getId(), 'subscribeType' => Subscribe::TYPE_COMMUNITY], ['id' => 'DESC'], $seek->getLimit(), $seek->getOffset()); }
public function format(Profile $profile) : array { return ['profile' => $profile->toJSON(), 'collections' => $this->formatCollections($profile->getCollections()), 'bookmarks' => array_map(function (ProfileCommunityEQ $eq) { return $eq->toJSON(); }, $this->communityBookmarksService->getBookmarksOfProfile($profile->getId())), 'is_own' => $this->currentAccountService->isAvailable() ? $this->currentAccountService->getCurrentAccount()->getProfiles()->contains($profile) : false]; }
private function createPostParameters(Profile $profile, Collection $collection, array $json) : CreatePostParameters { switch ((int) $json['typeId']) { default: throw new \Exception(sprintf('Unknown type_id `%s`', $json['type_id'])); case 0: // "content", simple post return new CreatePostParameters(DefaultPostType::CODE_INT, $profile->getId(), $collection->getId(), $json['description'], []); case 2: // youtube $url = $json['url']; $parsedURL = parse_url($url); if (!isset($parsedURL['host'])) { $url = 'https://www.youtube.com/watch?v=yKBLCcQObdQ'; $v = 'yKBLCcQObdQ'; } else { if (strtolower($parsedURL['host']) === 'youtu.be' || !isset($parsedURL['query'])) { $v = str_replace('/', '', $parsedURL['path']); } else { $params = []; parse_str(parse_url($url)['query'] ?? '', $params); $v = $params['v']; } } $linkAttachment = new Attachment(); $linkAttachment->setMetadata(['url' => $url, 'resource' => 'youtube', 'source' => ['source' => 'external', 'origURL' => $url], 'metadata' => ['og' => ['basic' => ['description' => '', 'title' => '', 'url' => $url], 'og' => ['basic' => ['og:url' => $url, 'og:title' => '', 'og:type' => '', 'og:description' => '', 'og:determiner' => '', 'og:locale' => '', 'og:locale:alternate' => '', 'og:site_name' => ''], 'images' => [['og:image' => '', 'og:image:url' => '', 'og:image:type' => '', 'og:image:width' => '', 'og:image:height' => '']], 'videos' => [['og:video' => '', 'og:video:url' => '', 'og:video:type' => '', 'og:video:width' => '', 'og:video:height' => '']], 'audios' => [['og:video' => '', 'og:video:url' => '', 'og:video:type' => '']]]], 'youtubeId' => $v]]); $this->attachmentRepository->createAttachment($linkAttachment); return new CreatePostParameters(DefaultPostType::CODE_INT, $profile->getId(), $collection->getId(), $json['description'] ?? '', [$linkAttachment->getId()]); case 3: // link $options = json_decode($json['options'], true); $url = $options['url']; $params = []; parse_str(parse_url($url)['query'] ?? '', $params); $title = $options['title'] ?? ''; $description = $options['description'] ?? ''; $image = $options['image'] ?? ''; $linkAttachment = new Attachment(); $linkAttachment->setMetadata(['url' => $url, 'resource' => 'page', 'source' => ['source' => 'external', 'origURL' => $url], 'metadata' => ['og' => ['basic' => ['description' => $description, 'title' => $title, 'url' => $url], 'og' => ['basic' => ['og:url' => $url, 'og:title' => $title, 'og:type' => '', 'og:description' => $description, 'og:determiner' => '', 'og:locale' => '', 'og:locale:alternate' => '', 'og:site_name' => ''], 'images' => [['og:image' => $image, 'og:image:url' => $image, 'og:image:type' => '', 'og:image:width' => '', 'og:image:height' => '']], 'videos' => [['og:video' => '', 'og:video:url' => '', 'og:video:type' => '', 'og:video:width' => '', 'og:video:height' => '']], 'audios' => [['og:video' => '', 'og:video:url' => '', 'og:video:type' => '']]]]]]); $this->attachmentRepository->createAttachment($linkAttachment); return new CreatePostParameters(DefaultPostType::CODE_INT, $profile->getId(), $collection->getId(), $json['description'] ?? '', [$linkAttachment->getId()]); } }