Example #1
0
 /**
  * @param Announcement $announcement
  * @return self
  */
 public static function fromAnnouncement(Announcement $announcement)
 {
     $self = new self();
     $self->setCity($announcement->getCity());
     $self->setDate($announcement->getDate());
     $lectures = new ArrayCollection();
     foreach ($announcement->getLectures() as $lectureAnnouncement) {
         $lecture = new Lecture();
         $lecture->setTitle($lectureAnnouncement->getTitle());
         $lecture->setTeaser($lectureAnnouncement->getTeaser());
         $lecture->setLecturer($lectureAnnouncement->getLecturer());
         $lecture->setField($lectureAnnouncement->getField());
         $lecture->setEvent($self);
         $lectures->add($lecture);
     }
     $self->lectures = $lectures;
     $self->created = new \DateTime();
     //todo this should be set automatically, why it is not?
     return $self;
 }
Example #2
0
 /**
  * @param Lecture $lecture
  * @return int
  */
 private function getCommentsCount(Lecture $lecture)
 {
     /** @var CommentThread|null $thread */
     $thread = $this->getContainer()->get('repository.comment_thread')->find($lecture->getId());
     return $thread ? $thread->getNumComments() : 0;
 }
Example #3
0
 /**
  * @param Lecture $lecture
  * @return bool
  */
 public function didLectureFav(Lecture $lecture)
 {
     return in_array($lecture->getId(), $this->favoriteLectureIds);
 }