<?php
namespace App\Entity;
use App\Entity\Webmail\Account;
use App\Repository\SectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: SectionRepository::class)]
class Section
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 40)]
private $name;
#[ORM\Column(type: 'string', length: 5)]
private $acronym;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Season::class)]
private $seasons;
#[ORM\OneToOne(mappedBy: 'section', targetEntity: SectionInfo::class, cascade: ['persist', 'remove'])]
private $sectionInfo;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: SectionMeta::class)]
private $sectionMetas;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: SectionPerson::class)]
private $sectionPersons;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Tag::class)]
private $tags;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: AdminSection::class, orphanRemoval: true)]
private $adminSections;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: ItemVariationSection::class)]
private $itemVariationSections;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: PersonCategory::class)]
private $personCategories;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Donation::class, cascade: ['remove'])]
private Collection $donations;
#[ORM\OneToMany(mappedBy: 'section', targetEntity: Account::class)]
private Collection $webmailAccounts;
public function __construct()
{
$this->seasons = new ArrayCollection();
$this->sectionMetas = new ArrayCollection();
$this->sectionPersons = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->adminSections = new ArrayCollection();
$this->itemVariationSections = new ArrayCollection();
$this->setSectionInfo(new SectionInfo());
$this->personCategories = new ArrayCollection();
$this->donations = new ArrayCollection();
$this->webmailAccounts = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, Season>
*/
public function getSeasons(): Collection
{
return $this->seasons;
}
public function addSeason(Season $season): self
{
if (!$this->seasons->contains($season)) {
$this->seasons[] = $season;
$season->setSection($this);
}
return $this;
}
public function removeSeason(Season $season): self
{
if ($this->seasons->removeElement($season)) {
// set the owning side to null (unless already changed)
if ($season->getSection() === $this) {
$season->setSection(null);
}
}
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getAcronym(): ?string
{
return $this->acronym;
}
public function setAcronym(string $acronym): self
{
$this->acronym = $acronym;
return $this;
}
public function getSectionInfo(): ?SectionInfo
{
return $this->sectionInfo;
}
public function setSectionInfo(SectionInfo $sectionInfo): self
{
// set the owning side of the relation if necessary
if ($sectionInfo->getSection() !== $this) {
$sectionInfo->setSection($this);
}
$this->sectionInfo = $sectionInfo;
return $this;
}
/**
* @return Collection<int, SectionMeta>
*/
public function getSectionMetas(): Collection
{
return $this->sectionMetas;
}
public function addSectionMeta(SectionMeta $sectionMeta): self
{
if (!$this->sectionMetas->contains($sectionMeta)) {
$this->sectionMetas[] = $sectionMeta;
$sectionMeta->setSection($this);
}
return $this;
}
public function removeSectionMeta(SectionMeta $sectionMeta): self
{
if ($this->sectionMetas->removeElement($sectionMeta)) {
// set the owning side to null (unless already changed)
if ($sectionMeta->getSection() === $this) {
$sectionMeta->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, SectionPerson>
*/
public function getSectionPersons(): Collection
{
return $this->sectionPersons;
}
public function addSectionPerson(SectionPerson $sectionPerson): self
{
if (!$this->sectionPersons->contains($sectionPerson)) {
$this->sectionPersons[] = $sectionPerson;
$sectionPerson->setSection($this);
}
return $this;
}
public function removeSectionPerson(SectionPerson $sectionPerson): self
{
if ($this->sectionPersons->removeElement($sectionPerson)) {
// set the owning side to null (unless already changed)
if ($sectionPerson->getSection() === $this) {
$sectionPerson->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): self
{
if (!$this->tags->contains($tag)) {
$this->tags[] = $tag;
$tag->setSection($this);
}
return $this;
}
public function removeTag(Tag $tag): self
{
if ($this->tags->removeElement($tag)) {
// set the owning side to null (unless already changed)
if ($tag->getSection() === $this) {
$tag->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, AdminSection>
*/
public function getAdminSections(): Collection
{
return $this->adminSections;
}
public function addAdminSection(AdminSection $adminSection): self
{
if (!$this->adminSections->contains($adminSection)) {
$this->adminSections[] = $adminSection;
$adminSection->setSection($this);
}
return $this;
}
public function removeAdminSection(AdminSection $adminSection): self
{
if ($this->adminSections->removeElement($adminSection)) {
// set the owning side to null (unless already changed)
if ($adminSection->getSection() === $this) {
$adminSection->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, ItemVariationSection>
*/
public function getItemVariationSections(): Collection
{
return $this->itemVariationSections;
}
public function addItemVariationSection(ItemVariationSection $itemVariationSection): self
{
if (!$this->itemVariationSections->contains($itemVariationSection)) {
$this->itemVariationSections[] = $itemVariationSection;
$itemVariationSection->setSection($this);
}
return $this;
}
public function removeItemVariationSection(ItemVariationSection $itemVariationSection): self
{
if ($this->itemVariationSections->removeElement($itemVariationSection)) {
// set the owning side to null (unless already changed)
if ($itemVariationSection->getSection() === $this) {
$itemVariationSection->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, PersonCategory>
*/
public function getPersonCategories(): Collection
{
return $this->personCategories;
}
public function addPersonCategory(PersonCategory $personCategory): self
{
if (!$this->personCategories->contains($personCategory)) {
$this->personCategories[] = $personCategory;
$personCategory->setSection($this);
}
return $this;
}
public function removePersonCategory(PersonCategory $personCategory): self
{
if ($this->personCategories->removeElement($personCategory)) {
// set the owning side to null (unless already changed)
if ($personCategory->getSection() === $this) {
$personCategory->setSection(null);
}
}
return $this;
}
public function getActiveSeason(): ?Season
{
foreach ($this->getSeasons() as $season) {
if ($season->getIsActive()) {
return $season;
}
}
return null;
}
/**
* @return Collection<int, Donation>
*/
public function getDonations(): Collection
{
return $this->donations;
}
public function addDonation(Donation $donation): self
{
if (!$this->donations->contains($donation)) {
$this->donations->add($donation);
$donation->setSection($this);
}
return $this;
}
public function removeDonation(Donation $donation): self
{
if ($this->donations->removeElement($donation)) {
// set the owning side to null (unless already changed)
if ($donation->getSection() === $this) {
$donation->setSection(null);
}
}
return $this;
}
/**
* @return Collection<int, Account>
*/
public function getWebmailAccounts(): Collection
{
return $this->webmailAccounts;
}
public function addWebmailAccount(Account $webmailAccount): self
{
if (!$this->webmailAccounts->contains($webmailAccount)) {
$this->webmailAccounts->add($webmailAccount);
$webmailAccount->setSection($this);
}
return $this;
}
public function removeWebmailAccount(Account $webmailAccount): self
{
if ($this->webmailAccounts->removeElement($webmailAccount)) {
// set the owning side to null (unless already changed)
if ($webmailAccount->getSection() === $this) {
$webmailAccount->setSection(null);
}
}
return $this;
}
}