<?php
namespace App\Entity;
use App\Repository\SpeakerCourseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=SpeakerCourseRepository::class)
*/
class SpeakerCourse
{
use RemoveImageTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Speaker::class, inversedBy="courses")
* @ORM\JoinColumn(nullable=false)
* @Assert\NotBlank()
*/
private $speaker;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
private $name;
/**
* @ORM\ManyToMany(targetEntity=Category::class)
*/
private $categories;
/**
* @ORM\Column(type="text")
* @Assert\NotBlank()
*/
private $shortDescription;
/**
* @ORM\Column(type="integer")
*/
private $price = 0;
/**
* @ORM\Column(type="integer")
*/
private $position = 0;
/**
* @ORM\Column(type="boolean")
*/
private $enabled = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $publishedDate;
/**
* @ORM\ManyToMany(targetEntity=User::class, inversedBy="courses")
*/
private $participants;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class, cascade={"persist", "remove"})
*/
private $thumbnailMediaFile;
/**
* @ORM\ManyToOne(targetEntity=MediaObject::class)
*/
private $videoMediaFile;
public function __construct()
{
$this->categories = new ArrayCollection();
$this->participants = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSpeaker(): ?Speaker
{
return $this->speaker;
}
public function setSpeaker(?Speaker $speaker): self
{
$this->speaker = $speaker;
return $this;
}
public function getVideo(): ?string
{
return (string) $this->getVideoMediaFile();
}
public function getThumbnail(): ?string
{
return (string) $this->getThumbnailMediaFile();
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|Category[]
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Category $category): self
{
if (!$this->categories->contains($category)) {
$this->categories[] = $category;
}
return $this;
}
public function removeCategory(Category $category): self
{
$this->categories->removeElement($category);
return $this;
}
public function getShortDescription(): ?string
{
return $this->shortDescription;
}
public function setShortDescription(string $shortDescription): self
{
$this->shortDescription = $shortDescription;
return $this;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): self
{
$this->price = (int) $price;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
public function getEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
if ($this->enabled) {
$this->setPublishedDate(new \DateTime());
}
return $this;
}
public function getPublishedDate(): ?\DateTimeInterface
{
return $this->publishedDate;
}
public function setPublishedDate(?\DateTimeInterface $publishedDate): self
{
$this->publishedDate = $publishedDate;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getParticipants(): Collection
{
return $this->participants;
}
public function addParticipant(User $participant): self
{
if (!$this->participants->contains($participant)) {
$this->participants[] = $participant;
}
return $this;
}
public function removeParticipant(User $participant): self
{
$this->participants->removeElement($participant);
return $this;
}
public function __toString()
{
return $this->getName();
}
public function getThumbnailMediaFile(): ?MediaObject
{
return $this->thumbnailMediaFile;
}
public function setThumbnailMediaFile(?MediaObject $thumbnailMediaFile): self
{
$this->thumbnailMediaFile = $thumbnailMediaFile;
return $this;
}
public function getVideoMediaFile(): ?MediaObject
{
return $this->videoMediaFile;
}
public function setVideoMediaFile(?MediaObject $videoMediaFile): self
{
$this->videoMediaFile = $videoMediaFile;
return $this;
}
}