<?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\BFFestivalRepository")
*/
class BFFestival extends AbstractArrayAccess
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFEdition", mappedBy="festival", orphanRemoval=true, cascade={"persist"})
* @ORM\OrderBy({"enddate" = "DESC", "startdate" = "DESC"})
*/
private $editions;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BFDescriptionFestival", inversedBy="festival", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $description;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\BFUser", inversedBy="ownedfestivals")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $owner;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFUser", inversedBy="administratorfestivals")
*/
private $administrators;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFAdminLicences", mappedBy="festival", cascade={"persist", "remove"})
*/
private $BFAdminLicences;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BFRouting", mappedBy="festival", cascade={"persist", "remove"})
*/
private $route;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFSubscription", mappedBy="festival", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $subscriptions;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFMailFestival", mappedBy="festival", cascade={"persist", "remove"})
*/
private $mails;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $creationdate;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFChallenge", mappedBy="festivals")
*/
private $challenges;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $orderfeebf;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $stripeaccountid;
const defaultfee=50;
public function __construct()
{
$this->editions = new ArrayCollection();
$this->description= new BFDescriptionFestival();
$this->administrators = new ArrayCollection();
$this->BFAdminLicences = new ArrayCollection();
$this->subscriptions = new ArrayCollection();
$this->mails = new ArrayCollection();
$this->creationdate = new \DateTime('now');
$this->challenges = 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|BFEdition[]
*/
public function getEditions(): Collection
{
return $this->editions;
}
public function addEdition(BFEdition $edition): self
{
if (!$this->editions->contains($edition)) {
$this->editions[] = $edition;
$edition->setFestivalid($this);
}
return $this;
}
public function removeEdition(BFEdition $edition): self
{
if ($this->editions->contains($edition)) {
$this->editions->removeElement($edition);
// set the owning side to null (unless already changed)
if ($edition->getFestivalid() === $this) {
$edition->setFestivalid(null);
}
}
return $this;
}
public function getDescription(): ?BFDescriptionFestival
{
return $this->description;
}
public function setDescription(BFDescriptionFestival $description): self
{
$this->description = $description;
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;
}
/**
* @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->setFestival($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->getFestival() === $this) {
$bFAdminLicence->setFestival(null);
}
}
return $this;
}
public function getCountActive(): int
{
$count=0;
foreach($this->getEditions() as $edition)
{
if($edition->getIsactive()==true)
$count++;
}
return $count;
}
public function getRoute(): ?BFRouting
{
return $this->route;
}
public function setRoute(?BFRouting $route): self
{
$this->route = $route;
// set (or unset) the owning side of the relation if necessary
$newFestival = null === $route ? null : $this;
if ($route->getFestival() !== $newFestival) {
$route->setFestival($newFestival);
}
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->setFestival($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->getFestival() === $this) {
$subscription->setFestival(null);
}
}
return $this;
}
/**
* @return Collection|BFMailFestival[]
*/
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 getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(?\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
/**
* @return Collection|BFChallenge[]
*/
public function getChallenges(): Collection
{
return $this->challenges;
}
public function addChallenge(BFChallenge $challenge): self
{
if (!$this->challenges->contains($challenge)) {
$this->challenges[] = $challenge;
$challenge->addFestival($this);
}
return $this;
}
public function removeChallenge(BFChallenge $challenge): self
{
if ($this->challenges->contains($challenge)) {
$this->challenges->removeElement($challenge);
$challenge->removeFestival($this);
}
return $this;
}
public function getNamelist()
{
return $this->id."-".$this->name;
}
public function getOrderfeebf(): ?int
{
if($this->orderfeebf==null)
return self::defaultfee;
return $this->orderfeebf;
}
public function setOrderfeebf(?int $orderfeebf): self
{
$this->orderfeebf = $orderfeebf;
return $this;
}
public function getStripeaccountid(): ?string
{
return $this->stripeaccountid;
}
public function setStripeaccountid(?string $stripeaccountid): self
{
$this->stripeaccountid = $stripeaccountid;
return $this;
}
}