private function createEpisode($info) { $episode = new Episode(); $episode->setIdTrakt($info['ids']['trakt'])->setIdTvdb($info['ids']['tvdb'])->setSummary($info['overview'])->setNumber($info['number'])->setAired(new \DateTime($info['first_aired']))->setTitle($info['title'])->setRating($info['rating']); $this->insertImage($episode, $info['images']); return $episode; }
/** * @Route("/episode/{uniqID}.{_format}", name="oktothek_show_episode", defaults={"_format": "html"}) * @Method("GET") * @Template() */ public function showEpisodeAction(Request $request, Episode $episode) { $this->get('bprs_analytics')->trackInfo($request, $episode->getUniqID()); $episodes = $this->getDoctrine()->getRepository('AppBundle:Episode')->findNewerEpisodes($episode, 3); $next = $this->getDoctrine()->getRepository('AppBundle:Episode')->findNextEpisode($episode); return ['episode' => $episode, 'related' => $episodes, 'next' => $next]; }
public function findNewerEpisodes(Episode $episode, $numberEpisodes = 3) { return $this->getEntityManager()->createQuery('SELECT e FROM AppBundle:Episode e WHERE e.series = :series_id AND e.onlineStart > :episode_date AND e.isActive = 1 ORDER BY e.onlineStart ASC')->setParameter('series_id', $episode->getSeries()->getId())->setParameter('episode_date', $episode->getOnlineStart())->setMaxResults($numberEpisodes)->getResult(); }
public function publishEpisode(Episode $episode) { if ($episode->getTechnicalStatus() >= Episode::STATE_READY) { // $this->logger->info(); $episode->setIsActive(true); $episode->setOnlineStart(new \Datetime()); $this->em->persist($episode); $this->em->flush(); $this->notificator->createNewEpisodeNotifications($episode); return true; } // can't publish episode if not ready return false; }
public function searchRelatedEpisodes(Episode $episode, $numberResults = 5) { $tagtext = implode(" ", $episode->getTags()->toArray()); $boolQuery = new \Elastica\Query\BoolQuery(); $multiquery = new \Elastica\Query\MultiMatch(); $multiquery->setFields(['name', 'description', 'series']); $multiquery->setQuery($tagtext); $multiquery->setType(\Elastica\Query\MultiMatch::TYPE_MOST_FIELDS); $boolQuery->addMust($multiquery); $activeQuery = new \Elastica\Query\Term(); $activeQuery->setTerm('is_active', true); $boolQuery->addMust($activeQuery); $excludeEpisodeQuery = new \Elastica\Query\Term(); $excludeEpisodeQuery->setTerm('id', $episode->getId()); $boolQuery->addMustNot($excludeEpisodeQuery); return $this->episodeFinder->find($boolQuery, $numberResults); }
public function createNewEpisodeNotifications(Episode $episode) { $notifications = []; $mails = []; foreach ($episode->getSeries()->getAbonnements() as $abonnement) { if ($abonnement->getNewEpisode()) { $notification = new Notification(); $notification->setEpisode($episode); $notification->setType(Notification::NEW_EPISODE); $abonnement->getUser()->addNotification($notification); $notifications[] = $notification; if ($abonnement->getSendMails()) { $mails[] = $notification; } } } $this->sendMails(Notification::NEW_EPISODE, $mails); $this->saveNotifications($notifications); }
/** * Add episode * * @param \AppBundle\Entity\Episode $episode * * @return Season */ public function addEpisode(\AppBundle\Entity\Episode $episode) { $this->episodes[] = $episode; $episode->setSeason($this); return $this; }
/** * @Route("/channel/episode/{uniqID}", name="oktothek_channel_episode") * @Method({"GET"}) * @Template() */ public function episodeAction(Episode $episode) { $this->denyAccessUnlessGranted('view_channel', $episode->getSeries()); $analytics = $this->get('oktothek_producer_analytics'); $clicks2weeks = $analytics->getAnalyticsForEpisode($episode); $clicks48 = $analytics->getAnalyticsForEpisode($episode, '+1 hour', '-2 days'); return ['episode' => $episode, 'clicks2weeks' => $clicks2weeks, 'clicks48' => $clicks48]; }