src/Entity/Section.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Webmail\Account;
  4. use App\Repository\SectionRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassSectionRepository::class)]
  9. class Section
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length40)]
  16.     private $name;
  17.     #[ORM\Column(type'string'length5)]
  18.     private $acronym;
  19.     #[ORM\OneToMany(mappedBy'section'targetEntitySeason::class)]
  20.     private $seasons;
  21.     #[ORM\OneToOne(mappedBy'section'targetEntitySectionInfo::class, cascade: ['persist''remove'])]
  22.     private $sectionInfo;
  23.     #[ORM\OneToMany(mappedBy'section'targetEntitySectionMeta::class)]
  24.     private $sectionMetas;
  25.     #[ORM\OneToMany(mappedBy'section'targetEntitySectionPerson::class)]
  26.     private $sectionPersons;
  27.     #[ORM\OneToMany(mappedBy'section'targetEntityTag::class)]
  28.     private $tags;
  29.     #[ORM\OneToMany(mappedBy'section'targetEntityAdminSection::class, orphanRemovaltrue)]
  30.     private $adminSections;
  31.     #[ORM\OneToMany(mappedBy'section'targetEntityItemVariationSection::class)]
  32.     private $itemVariationSections;
  33.     #[ORM\OneToMany(mappedBy'section'targetEntityPersonCategory::class)]
  34.     private $personCategories;
  35.     #[ORM\OneToMany(mappedBy'section'targetEntityDonation::class, cascade: ['remove'])]
  36.     private Collection $donations;
  37.     #[ORM\OneToMany(mappedBy'section'targetEntityAccount::class)]
  38.     private Collection $webmailAccounts;
  39.     public function __construct()
  40.     {
  41.         $this->seasons = new ArrayCollection();
  42.         $this->sectionMetas = new ArrayCollection();
  43.         $this->sectionPersons = new ArrayCollection();
  44.         $this->tags = new ArrayCollection();
  45.         $this->adminSections = new ArrayCollection();
  46.         $this->itemVariationSections = new ArrayCollection();
  47.         $this->setSectionInfo(new SectionInfo());
  48.         $this->personCategories = new ArrayCollection();
  49.         $this->donations = new ArrayCollection();
  50.         $this->webmailAccounts = new ArrayCollection();
  51.     }
  52.     public function __toString(): string
  53.     {
  54.         return $this->getName();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     /**
  61.      * @return Collection<int, Season>
  62.      */
  63.     public function getSeasons(): Collection
  64.     {
  65.         return $this->seasons;
  66.     }
  67.     public function addSeason(Season $season): self
  68.     {
  69.         if (!$this->seasons->contains($season)) {
  70.             $this->seasons[] = $season;
  71.             $season->setSection($this);
  72.         }
  73.         return $this;
  74.     }
  75.     public function removeSeason(Season $season): self
  76.     {
  77.         if ($this->seasons->removeElement($season)) {
  78.             // set the owning side to null (unless already changed)
  79.             if ($season->getSection() === $this) {
  80.                 $season->setSection(null);
  81.             }
  82.         }
  83.         return $this;
  84.     }
  85.     public function getName(): ?string
  86.     {
  87.         return $this->name;
  88.     }
  89.     public function setName(string $name): self
  90.     {
  91.         $this->name $name;
  92.         return $this;
  93.     }
  94.     public function getAcronym(): ?string
  95.     {
  96.         return $this->acronym;
  97.     }
  98.     public function setAcronym(string $acronym): self
  99.     {
  100.         $this->acronym $acronym;
  101.         return $this;
  102.     }
  103.     public function getSectionInfo(): ?SectionInfo
  104.     {
  105.         return $this->sectionInfo;
  106.     }
  107.     public function setSectionInfo(SectionInfo $sectionInfo): self
  108.     {
  109.         // set the owning side of the relation if necessary
  110.         if ($sectionInfo->getSection() !== $this) {
  111.             $sectionInfo->setSection($this);
  112.         }
  113.         $this->sectionInfo $sectionInfo;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, SectionMeta>
  118.      */
  119.     public function getSectionMetas(): Collection
  120.     {
  121.         return $this->sectionMetas;
  122.     }
  123.     public function addSectionMeta(SectionMeta $sectionMeta): self
  124.     {
  125.         if (!$this->sectionMetas->contains($sectionMeta)) {
  126.             $this->sectionMetas[] = $sectionMeta;
  127.             $sectionMeta->setSection($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeSectionMeta(SectionMeta $sectionMeta): self
  132.     {
  133.         if ($this->sectionMetas->removeElement($sectionMeta)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($sectionMeta->getSection() === $this) {
  136.                 $sectionMeta->setSection(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection<int, SectionPerson>
  143.      */
  144.     public function getSectionPersons(): Collection
  145.     {
  146.         return $this->sectionPersons;
  147.     }
  148.     public function addSectionPerson(SectionPerson $sectionPerson): self
  149.     {
  150.         if (!$this->sectionPersons->contains($sectionPerson)) {
  151.             $this->sectionPersons[] = $sectionPerson;
  152.             $sectionPerson->setSection($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeSectionPerson(SectionPerson $sectionPerson): self
  157.     {
  158.         if ($this->sectionPersons->removeElement($sectionPerson)) {
  159.             // set the owning side to null (unless already changed)
  160.             if ($sectionPerson->getSection() === $this) {
  161.                 $sectionPerson->setSection(null);
  162.             }
  163.         }
  164.         return $this;
  165.     }
  166.     /**
  167.      * @return Collection<int, Tag>
  168.      */
  169.     public function getTags(): Collection
  170.     {
  171.         return $this->tags;
  172.     }
  173.     public function addTag(Tag $tag): self
  174.     {
  175.         if (!$this->tags->contains($tag)) {
  176.             $this->tags[] = $tag;
  177.             $tag->setSection($this);
  178.         }
  179.         return $this;
  180.     }
  181.     public function removeTag(Tag $tag): self
  182.     {
  183.         if ($this->tags->removeElement($tag)) {
  184.             // set the owning side to null (unless already changed)
  185.             if ($tag->getSection() === $this) {
  186.                 $tag->setSection(null);
  187.             }
  188.         }
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, AdminSection>
  193.      */
  194.     public function getAdminSections(): Collection
  195.     {
  196.         return $this->adminSections;
  197.     }
  198.     public function addAdminSection(AdminSection $adminSection): self
  199.     {
  200.         if (!$this->adminSections->contains($adminSection)) {
  201.             $this->adminSections[] = $adminSection;
  202.             $adminSection->setSection($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeAdminSection(AdminSection $adminSection): self
  207.     {
  208.         if ($this->adminSections->removeElement($adminSection)) {
  209.             // set the owning side to null (unless already changed)
  210.             if ($adminSection->getSection() === $this) {
  211.                 $adminSection->setSection(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, ItemVariationSection>
  218.      */
  219.     public function getItemVariationSections(): Collection
  220.     {
  221.         return $this->itemVariationSections;
  222.     }
  223.     public function addItemVariationSection(ItemVariationSection $itemVariationSection): self
  224.     {
  225.         if (!$this->itemVariationSections->contains($itemVariationSection)) {
  226.             $this->itemVariationSections[] = $itemVariationSection;
  227.             $itemVariationSection->setSection($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeItemVariationSection(ItemVariationSection $itemVariationSection): self
  232.     {
  233.         if ($this->itemVariationSections->removeElement($itemVariationSection)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($itemVariationSection->getSection() === $this) {
  236.                 $itemVariationSection->setSection(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, PersonCategory>
  243.      */
  244.     public function getPersonCategories(): Collection
  245.     {
  246.         return $this->personCategories;
  247.     }
  248.     public function addPersonCategory(PersonCategory $personCategory): self
  249.     {
  250.         if (!$this->personCategories->contains($personCategory)) {
  251.             $this->personCategories[] = $personCategory;
  252.             $personCategory->setSection($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removePersonCategory(PersonCategory $personCategory): self
  257.     {
  258.         if ($this->personCategories->removeElement($personCategory)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($personCategory->getSection() === $this) {
  261.                 $personCategory->setSection(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     public function getActiveSeason(): ?Season
  267.     {
  268.         foreach ($this->getSeasons() as $season) {
  269.             if ($season->getIsActive()) {
  270.                 return $season;
  271.             }
  272.         }
  273.         return null;
  274.     }
  275.     /**
  276.      * @return Collection<int, Donation>
  277.      */
  278.     public function getDonations(): Collection
  279.     {
  280.         return $this->donations;
  281.     }
  282.     public function addDonation(Donation $donation): self
  283.     {
  284.         if (!$this->donations->contains($donation)) {
  285.             $this->donations->add($donation);
  286.             $donation->setSection($this);
  287.         }
  288.         return $this;
  289.     }
  290.     public function removeDonation(Donation $donation): self
  291.     {
  292.         if ($this->donations->removeElement($donation)) {
  293.             // set the owning side to null (unless already changed)
  294.             if ($donation->getSection() === $this) {
  295.                 $donation->setSection(null);
  296.             }
  297.         }
  298.         return $this;
  299.     }
  300.     /**
  301.      * @return Collection<int, Account>
  302.      */
  303.     public function getWebmailAccounts(): Collection
  304.     {
  305.         return $this->webmailAccounts;
  306.     }
  307.     public function addWebmailAccount(Account $webmailAccount): self
  308.     {
  309.         if (!$this->webmailAccounts->contains($webmailAccount)) {
  310.             $this->webmailAccounts->add($webmailAccount);
  311.             $webmailAccount->setSection($this);
  312.         }
  313.         return $this;
  314.     }
  315.     public function removeWebmailAccount(Account $webmailAccount): self
  316.     {
  317.         if ($this->webmailAccounts->removeElement($webmailAccount)) {
  318.             // set the owning side to null (unless already changed)
  319.             if ($webmailAccount->getSection() === $this) {
  320.                 $webmailAccount->setSection(null);
  321.             }
  322.         }
  323.         return $this;
  324.     }
  325. }