src/Entity/Season.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SeasonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups// Add this use statement
  9. #[ORM\Entity(repositoryClassSeasonRepository::class)]
  10. class Season
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     #[Groups(["chat:channel:list""chat_message"])] // Add group
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     #[Groups(["chat:channel:list""chat_message"])] // Add group
  19.     private ?string $name null;
  20.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  21.     private ?\DateTimeInterface $startDate null;
  22.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  23.     private ?\DateTimeInterface $endDate null;
  24.     #[ORM\Column]
  25.     private ?bool $isActive null;
  26.     #[ORM\ManyToOne(inversedBy'seasons')]
  27.     #[ORM\JoinColumn(nullablefalse)]
  28.     private ?Company $company null;
  29.     #[ORM\OneToMany(mappedBy'season'targetEntityTeamSeason::class, orphanRemovaltrue)]
  30.     private Collection $teamSeasons;
  31.     #[ORM\OneToMany(mappedBy'season'targetEntitySubmission::class)]
  32.     private Collection $submissions;
  33.     #[ORM\OneToMany(mappedBy'season'targetEntityActivityConfiguration::class, orphanRemovaltrue)]
  34.     private Collection $activityConfigurations;
  35.     #[ORM\Column(length50)]
  36.     private ?string $defaultValidationMethod 'automatic';
  37.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  38.     private ?array $activityConfig null;
  39.     
  40.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  41.     private ?string $summary null;
  42.     
  43.     #[ORM\Column(length255nullabletrue)]
  44.     private ?string $imageFilename null;
  45.     
  46.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  47.     private ?string $rewards null;
  48.     #[ORM\OneToOne(mappedBy'season'cascade: ['persist''remove'])]
  49.     private ?SeasonGoogleChatConfig $googleChatConfig null;
  50.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  51.     private bool $useBalancedScoring false;
  52.     public function __toString(): string
  53.     {
  54.         return $this->getName();
  55.     }
  56.     public function __construct()
  57.     {
  58.         $this->teamSeasons = new ArrayCollection();
  59.         $this->submissions = new ArrayCollection();
  60.         $this->activityConfigurations = new ArrayCollection();
  61.         $this->isActive false;
  62.         $this->useBalancedScoring false;
  63.     }
  64.     public function getId(): ?int
  65.     {
  66.         return $this->id;
  67.     }
  68.     public function getName(): ?string
  69.     {
  70.         return $this->name;
  71.     }
  72.     public function setName(string $name): static
  73.     {
  74.         $this->name $name;
  75.         return $this;
  76.     }
  77.     public function getStartDate(): ?\DateTimeInterface
  78.     {
  79.         return $this->startDate;
  80.     }
  81.     public function setStartDate(\DateTimeInterface $startDate): static
  82.     {
  83.         $this->startDate $startDate;
  84.         return $this;
  85.     }
  86.     public function getEndDate(): ?\DateTimeInterface
  87.     {
  88.         return $this->endDate;
  89.     }
  90.     public function setEndDate(\DateTimeInterface $endDate): static
  91.     {
  92.         $this->endDate $endDate;
  93.         return $this;
  94.     }
  95.     public function isIsActive(): ?bool
  96.     {
  97.         return $this->isActive;
  98.     }
  99.     public function setIsActive(bool $isActive): static
  100.     {
  101.         $this->isActive $isActive;
  102.         return $this;
  103.     }
  104.     public function getCompany(): ?Company
  105.     {
  106.         return $this->company;
  107.     }
  108.     public function setCompany(?Company $company): static
  109.     {
  110.         $this->company $company;
  111.         return $this;
  112.     }
  113.     /**
  114.      * @return Collection<int, TeamSeason>
  115.      */
  116.     public function getTeamSeasons(): Collection
  117.     {
  118.         return $this->teamSeasons;
  119.     }
  120.     public function addTeamSeason(TeamSeason $teamSeason): static
  121.     {
  122.         if (!$this->teamSeasons->contains($teamSeason)) {
  123.             $this->teamSeasons->add($teamSeason);
  124.             $teamSeason->setSeason($this);
  125.         }
  126.         return $this;
  127.     }
  128.     public function removeTeamSeason(TeamSeason $teamSeason): static
  129.     {
  130.         if ($this->teamSeasons->removeElement($teamSeason)) {
  131.             // set the owning side to null (unless already changed)
  132.             if ($teamSeason->getSeason() === $this) {
  133.                 $teamSeason->setSeason(null);
  134.             }
  135.         }
  136.         return $this;
  137.     }
  138.     /**
  139.      * @return Collection<int, Submission>
  140.      */
  141.     public function getSubmissions(): Collection
  142.     {
  143.         return $this->submissions;
  144.     }
  145.     public function addSubmission(Submission $submission): static
  146.     {
  147.         if (!$this->submissions->contains($submission)) {
  148.             $this->submissions->add($submission);
  149.             $submission->setSeason($this);
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeSubmission(Submission $submission): static
  154.     {
  155.         if ($this->submissions->removeElement($submission)) {
  156.             // set the owning side to null (unless already changed)
  157.             if ($submission->getSeason() === $this) {
  158.                 $submission->setSeason(null);
  159.             }
  160.         }
  161.         return $this;
  162.     }
  163.     /**
  164.      * Get all teams participating in this season
  165.      * 
  166.      * @return Collection<int, Team>
  167.      */
  168.     public function getTeams(): Collection
  169.     {
  170.         $teams = new ArrayCollection();
  171.         
  172.         foreach ($this->teamSeasons as $teamSeason) {
  173.             $teams->add($teamSeason->getTeam());
  174.         }
  175.         
  176.         return $teams;
  177.     }
  178.     /**
  179.      * Check if the season is currently active based on dates
  180.      */
  181.     public function isActive(): bool
  182.     {
  183.         $now = new \DateTime();
  184.         return $this->isActive && 
  185.                $this->startDate <= $now && 
  186.                $this->endDate >= $now;
  187.     }
  188.     /**
  189.      * @return Collection<int, ActivityConfiguration>
  190.      */
  191.     public function getActivityConfigurations(): Collection
  192.     {
  193.         return $this->activityConfigurations;
  194.     }
  195.     public function addActivityConfiguration(ActivityConfiguration $activityConfiguration): static
  196.     {
  197.         if (!$this->activityConfigurations->contains($activityConfiguration)) {
  198.             $this->activityConfigurations->add($activityConfiguration);
  199.             $activityConfiguration->setSeason($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeActivityConfiguration(ActivityConfiguration $activityConfiguration): static
  204.     {
  205.         if ($this->activityConfigurations->removeElement($activityConfiguration)) {
  206.             // set the owning side to null (unless already changed)
  207.             if ($activityConfiguration->getSeason() === $this) {
  208.                 $activityConfiguration->setSeason(null);
  209.             }
  210.         }
  211.         return $this;
  212.     }
  213.     public function getDefaultValidationMethod(): ?string
  214.     {
  215.         return $this->defaultValidationMethod;
  216.     }
  217.     public function setDefaultValidationMethod(string $defaultValidationMethod): static
  218.     {
  219.         $this->defaultValidationMethod $defaultValidationMethod;
  220.         return $this;
  221.     }
  222.     public function getActivityConfig(): ?array
  223.     {
  224.         return $this->activityConfig;
  225.     }
  226.     public function setActivityConfig(?array $activityConfig): static
  227.     {
  228.         $this->activityConfig $activityConfig;
  229.         return $this;
  230.     }
  231.     
  232.     public function getSummary(): ?string
  233.     {
  234.         return $this->summary;
  235.     }
  236.     
  237.     public function setSummary(?string $summary): static
  238.     {
  239.         $this->summary $summary;
  240.         
  241.         return $this;
  242.     }
  243.     
  244.     public function getImageFilename(): ?string
  245.     {
  246.         return $this->imageFilename;
  247.     }
  248.     
  249.     public function setImageFilename(?string $imageFilename): static
  250.     {
  251.         $this->imageFilename $imageFilename;
  252.         
  253.         return $this;
  254.     }
  255.     
  256.     public function getRewards(): ?string
  257.     {
  258.         return $this->rewards;
  259.     }
  260.     
  261.     public function setRewards(?string $rewards): static
  262.     {
  263.         $this->rewards $rewards;
  264.         
  265.         return $this;
  266.     }
  267.     /**
  268.      * Get activity configuration for a specific activity
  269.      */
  270.     public function getActivityConfigurationForActivity(Activity $activity): ?ActivityConfiguration
  271.     {
  272.         foreach ($this->activityConfigurations as $activityConfiguration) {
  273.             if ($activityConfiguration->getActivity() === $activity) {
  274.                 return $activityConfiguration;
  275.             }
  276.         }
  277.         
  278.         return null;
  279.     }
  280.     /**
  281.      * Get all enabled activities for this season
  282.      *
  283.      * @return Collection<int, Activity>
  284.      */
  285.     public function getEnabledActivities(): Collection
  286.     {
  287.         $activities = new ArrayCollection();
  288.         
  289.         foreach ($this->activityConfigurations as $activityConfiguration) {
  290.             if ($activityConfiguration->isIsEnabled()) {
  291.                 $activities->add($activityConfiguration->getActivity());
  292.             }
  293.         }
  294.         
  295.         return $activities;
  296.     }
  297.     public function getGoogleChatConfig(): ?SeasonGoogleChatConfig
  298.     {
  299.         return $this->googleChatConfig;
  300.     }
  301.     public function setGoogleChatConfig(SeasonGoogleChatConfig $googleChatConfig): static
  302.     {
  303.         // set the owning side of the relation if necessary
  304.         if ($googleChatConfig->getSeason() !== $this) {
  305.             $googleChatConfig->setSeason($this);
  306.         }
  307.         $this->googleChatConfig $googleChatConfig;
  308.         return $this;
  309.     }
  310.     public function getUseBalancedScoring(): bool
  311.     {
  312.         return $this->useBalancedScoring;
  313.     }
  314.     public function setUseBalancedScoring(bool $useBalancedScoring): static
  315.     {
  316.         $this->useBalancedScoring $useBalancedScoring;
  317.         return $this;
  318.     }
  319. }