<?php
namespace App\Entity;
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="App\Repository\BFChallengeRepository")
*/
class BFChallenge
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFFestival", inversedBy="challenges")
*/
private $festivals;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFUser", inversedBy="ownedChallenges")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $owner;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFUser", inversedBy="adminChallenges")
*/
private $administrators;
/**
* @ORM\Column(type="datetime")
*/
private $creationdate;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BFDescriptionChallenge", inversedBy="challenge", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $description;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFChallengeEdition", mappedBy="challenge",cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $editions;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFAdminLicences", mappedBy="challenge", cascade={"persist", "remove"})
*/
private $BFAdminLicences;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFSubscription", mappedBy="challenge")
*/
private $subscriptions;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFMailChallenge", mappedBy="festival")
*/
private $mails;
public function __construct()
{
$this->festivals = new ArrayCollection();
$this->administrators = new ArrayCollection();
$this->editions = new ArrayCollection();
$this->BFAdminLicences = new ArrayCollection();
$this->description= new BFDescriptionChallenge();
$this->creationdate = new \DateTime('now');
$this->subscriptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection|BFFestival[]
*/
public function getFestivals(): Collection
{
return $this->festivals;
}
public function addFestival(BFFestival $festival): self
{
if (!$this->festivals->contains($festival)) {
$this->festivals[] = $festival;
}
return $this;
}
public function removeFestival(BFFestival $festival): self
{
if ($this->festivals->contains($festival)) {
$this->festivals->removeElement($festival);
}
return $this;
}
public function getOwner(): ?BFUser
{
return $this->owner;
}
public function setOwner(?BFUser $owner): self
{
$this->owner = $owner;
return $this;
}
/**
* @return Collection|BFUser[]
*/
public function getAdministrators(): Collection
{
return $this->administrators;
}
public function addAdministrator(BFUser $administrator): self
{
if (!$this->administrators->contains($administrator)) {
$this->administrators[] = $administrator;
}
return $this;
}
public function removeAdministrator(BFUser $administrator): self
{
if ($this->administrators->contains($administrator)) {
$this->administrators->removeElement($administrator);
}
return $this;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
public function getDescription(): ?BFDescriptionChallenge
{
return $this->description;
}
public function setDescription(BFDescriptionChallenge $description): self
{
$this->description = $description;
// set the owning side of the relation if necessary
if ($description->getChallenge() !== $this) {
$description->setChallenge($this);
}
return $this;
}
/**
* @return Collection|BFChallengeEdition[]
*/
public function getEditions(): Collection
{
return $this->editions;
}
public function addEdition(BFChallengeEdition $edition): self
{
if (!$this->editions->contains($edition)) {
$this->editions[] = $edition;
$edition->setChallenge($this);
}
return $this;
}
public function removeEdition(BFChallengeEdition $edition): self
{
if ($this->editions->contains($edition)) {
$this->editions->removeElement($edition);
// set the owning side to null (unless already changed)
if ($edition->getChallenge() === $this) {
$edition->setChallenge(null);
}
}
return $this;
}
/**
* @return Collection|BFAdminLicences[]
*/
public function getBFAdminLicences(): Collection
{
return $this->BFAdminLicences;
}
public function addBFAdminLicence(BFAdminLicences $bFAdminLicence): self
{
if (!$this->BFAdminLicences->contains($bFAdminLicence)) {
$this->BFAdminLicences[] = $bFAdminLicence;
$bFAdminLicence->setChallenge($this);
}
return $this;
}
public function removeBFAdminLicence(BFAdminLicences $bFAdminLicence): self
{
if ($this->BFAdminLicences->contains($bFAdminLicence)) {
$this->BFAdminLicences->removeElement($bFAdminLicence);
// set the owning side to null (unless already changed)
if ($bFAdminLicence->getChallenge() === $this) {
$bFAdminLicence->setChallenge(null);
}
}
return $this;
}
/**
* @return Collection|BFSubscription[]
*/
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
public function addSubscription(BFSubscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions[] = $subscription;
$subscription->setChallenge($this);
}
return $this;
}
public function removeSubscription(BFSubscription $subscription): self
{
if ($this->subscriptions->contains($subscription)) {
$this->subscriptions->removeElement($subscription);
// set the owning side to null (unless already changed)
if ($subscription->getChallenge() === $this) {
$subscription->setChallenge(null);
}
}
return $this;
}
public function getMails(): Collection
{
return $this->mails;
}
public function addMail(BFMailFestival $mail): self
{
if (!$this->mails->contains($mail)) {
$this->mails[] = $mail;
$mail->setFestival($this);
}
return $this;
}
public function removeMail(BFMailFestival $mail): self
{
if ($this->mails->contains($mail)) {
$this->mails->removeElement($mail);
// set the owning side to null (unless already changed)
if ($mail->getFestival() === $this) {
$mail->setFestival(null);
}
}
return $this;
}
public function getCountActive(): int
{
$count=0;
foreach($this->getEditions() as $edition)
{
if($edition->getIsactive()==true)
$count++;
}
return $count;
}
}