src/Entity/BFChallenge.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\BFChallengeRepository")
  9.  */
  10. class BFChallenge
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\ManyToMany(targetEntity="App\Entity\BFFestival", inversedBy="challenges")
  24.      */
  25.     private $festivals;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity="App\Entity\BFUser", inversedBy="ownedChallenges")
  28.      * @ORM\JoinColumn(onDelete="SET NULL")
  29.      */
  30.     private $owner;
  31.     /**
  32.      * @ORM\ManyToMany(targetEntity="App\Entity\BFUser", inversedBy="adminChallenges")
  33.      */
  34.     private $administrators;
  35.     /**
  36.      * @ORM\Column(type="datetime")
  37.      */
  38.     private $creationdate;
  39.     /**
  40.      * @ORM\OneToOne(targetEntity="App\Entity\BFDescriptionChallenge", inversedBy="challenge", cascade={"persist", "remove"})
  41.      * @ORM\JoinColumn(nullable=false)
  42.      */
  43.     private $description;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity="App\Entity\BFChallengeEdition", mappedBy="challenge",cascade={"persist", "remove"}, orphanRemoval=true)
  46.      */
  47.     private $editions;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity="App\Entity\BFAdminLicences", mappedBy="challenge", cascade={"persist", "remove"})
  50.      */
  51.     private $BFAdminLicences;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity="App\Entity\BFSubscription", mappedBy="challenge")
  54.      */
  55.     private $subscriptions;
  56.     
  57.     /**
  58.      * @ORM\OneToMany(targetEntity="App\Entity\BFMailChallenge", mappedBy="festival")
  59.      */
  60.     private $mails;
  61.     public function __construct()
  62.     {
  63.         $this->festivals = new ArrayCollection();
  64.         $this->administrators = new ArrayCollection();
  65.         $this->editions = new ArrayCollection();
  66.         $this->BFAdminLicences = new ArrayCollection();
  67.         $this->description= new BFDescriptionChallenge();
  68.         $this->creationdate = new \DateTime('now');
  69.         $this->subscriptions = new ArrayCollection();
  70.     }
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getName(): ?string
  76.     {
  77.         return $this->name;
  78.     }
  79.     public function setName(string $name): self
  80.     {
  81.         $this->name $name;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection|BFFestival[]
  86.      */
  87.     public function getFestivals(): Collection
  88.     {
  89.         return $this->festivals;
  90.     }
  91.     public function addFestival(BFFestival $festival): self
  92.     {
  93.         if (!$this->festivals->contains($festival)) {
  94.             $this->festivals[] = $festival;
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeFestival(BFFestival $festival): self
  99.     {
  100.         if ($this->festivals->contains($festival)) {
  101.             $this->festivals->removeElement($festival);
  102.         }
  103.         return $this;
  104.     }
  105.     public function getOwner(): ?BFUser
  106.     {
  107.         return $this->owner;
  108.     }
  109.     public function setOwner(?BFUser $owner): self
  110.     {
  111.         $this->owner $owner;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection|BFUser[]
  116.      */
  117.     public function getAdministrators(): Collection
  118.     {
  119.         return $this->administrators;
  120.     }
  121.     public function addAdministrator(BFUser $administrator): self
  122.     {
  123.         if (!$this->administrators->contains($administrator)) {
  124.             $this->administrators[] = $administrator;
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeAdministrator(BFUser $administrator): self
  129.     {
  130.         if ($this->administrators->contains($administrator)) {
  131.             $this->administrators->removeElement($administrator);
  132.         }
  133.         return $this;
  134.     }
  135.     public function getCreationdate(): ?\DateTimeInterface
  136.     {
  137.         return $this->creationdate;
  138.     }
  139.     public function setCreationdate(\DateTimeInterface $creationdate): self
  140.     {
  141.         $this->creationdate $creationdate;
  142.         return $this;
  143.     }
  144.     public function getDescription(): ?BFDescriptionChallenge
  145.     {
  146.         return $this->description;
  147.     }
  148.     public function setDescription(BFDescriptionChallenge $description): self
  149.     {
  150.         $this->description $description;
  151.         // set the owning side of the relation if necessary
  152.         if ($description->getChallenge() !== $this) {
  153.             $description->setChallenge($this);
  154.         }
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return Collection|BFChallengeEdition[]
  159.      */
  160.     public function getEditions(): Collection
  161.     {
  162.         return $this->editions;
  163.     }
  164.     public function addEdition(BFChallengeEdition $edition): self
  165.     {
  166.         if (!$this->editions->contains($edition)) {
  167.             $this->editions[] = $edition;
  168.             $edition->setChallenge($this);
  169.         }
  170.         return $this;
  171.     }
  172.     public function removeEdition(BFChallengeEdition $edition): self
  173.     {
  174.         if ($this->editions->contains($edition)) {
  175.             $this->editions->removeElement($edition);
  176.             // set the owning side to null (unless already changed)
  177.             if ($edition->getChallenge() === $this) {
  178.                 $edition->setChallenge(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection|BFAdminLicences[]
  185.      */
  186.     public function getBFAdminLicences(): Collection
  187.     {
  188.         return $this->BFAdminLicences;
  189.     }
  190.     public function addBFAdminLicence(BFAdminLicences $bFAdminLicence): self
  191.     {
  192.         if (!$this->BFAdminLicences->contains($bFAdminLicence)) {
  193.             $this->BFAdminLicences[] = $bFAdminLicence;
  194.             $bFAdminLicence->setChallenge($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeBFAdminLicence(BFAdminLicences $bFAdminLicence): self
  199.     {
  200.         if ($this->BFAdminLicences->contains($bFAdminLicence)) {
  201.             $this->BFAdminLicences->removeElement($bFAdminLicence);
  202.             // set the owning side to null (unless already changed)
  203.             if ($bFAdminLicence->getChallenge() === $this) {
  204.                 $bFAdminLicence->setChallenge(null);
  205.             }
  206.         }
  207.         return $this;
  208.     }
  209.     /**
  210.      * @return Collection|BFSubscription[]
  211.      */
  212.     public function getSubscriptions(): Collection
  213.     {
  214.         return $this->subscriptions;
  215.     }
  216.     public function addSubscription(BFSubscription $subscription): self
  217.     {
  218.         if (!$this->subscriptions->contains($subscription)) {
  219.             $this->subscriptions[] = $subscription;
  220.             $subscription->setChallenge($this);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeSubscription(BFSubscription $subscription): self
  225.     {
  226.         if ($this->subscriptions->contains($subscription)) {
  227.             $this->subscriptions->removeElement($subscription);
  228.             // set the owning side to null (unless already changed)
  229.             if ($subscription->getChallenge() === $this) {
  230.                 $subscription->setChallenge(null);
  231.             }
  232.         }
  233.         return $this;
  234.     }
  235.     
  236.     public function getMails(): Collection
  237.     {
  238.         return $this->mails;
  239.     }
  240.     public function addMail(BFMailFestival $mail): self
  241.     {
  242.         if (!$this->mails->contains($mail)) {
  243.             $this->mails[] = $mail;
  244.             $mail->setFestival($this);
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeMail(BFMailFestival $mail): self
  249.     {
  250.         if ($this->mails->contains($mail)) {
  251.             $this->mails->removeElement($mail);
  252.             // set the owning side to null (unless already changed)
  253.             if ($mail->getFestival() === $this) {
  254.                 $mail->setFestival(null);
  255.             }
  256.         }
  257.         return $this;
  258.     }
  259.     
  260.     public function getCountActive(): int
  261.     {
  262.         $count=0;
  263.         
  264.         foreach($this->getEditions() as $edition)
  265.         {
  266.             if($edition->getIsactive()==true)
  267.                 $count++;
  268.         }
  269.         
  270.         return $count;
  271.     }
  272. }