src/Entity/Activity.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ActivityRepository;
  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. #[ORM\Entity(repositoryClassActivityRepository::class)]
  9. class Activity
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length255)]
  16.     private ?string $name null;
  17.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  18.     private ?string $description null;
  19.     #[ORM\Column]
  20.     private ?int $points null;
  21.     #[ORM\Column(length50)]
  22.     private ?string $category null;
  23.     #[ORM\Column(length50)]
  24.     private ?string $frequency null;
  25.     #[ORM\Column]
  26.     private ?int $maxPerPeriod null;
  27.     #[ORM\OneToMany(mappedBy'activity'targetEntitySubmission::class)]
  28.     private Collection $submissions;
  29.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  30.     private ?array $validationSchema null;
  31.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  32.     private ?array $evidenceSchema null;
  33.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  34.     private ?array $pointCalculationLogic null;
  35.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  36.     private ?array $validationRules null;
  37.     #[ORM\Column]
  38.     private ?bool $evidenceRequired false;
  39.     #[ORM\Column]
  40.     private ?bool $teamActivity false;
  41.     #[ORM\Column(typeTypes::JSONnullabletrue)]
  42.     private ?array $additionalFields null;
  43.     #[ORM\Column]
  44.     private ?bool $isActive true;
  45.     #[ORM\OneToMany(mappedBy'activity'targetEntityActivityConfiguration::class, orphanRemovaltrue)]
  46.     private Collection $activityConfigurations;
  47.     public function __toString(): string
  48.     {
  49.         return $this->getName();
  50.     }
  51.     public function __construct()
  52.     {
  53.         $this->submissions = new ArrayCollection();
  54.         $this->activityConfigurations = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getName(): ?string
  61.     {
  62.         return $this->name;
  63.     }
  64.     public function setName(string $name): static
  65.     {
  66.         $this->name $name;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(?string $description): static
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function getPoints(): ?int
  79.     {
  80.         return $this->points;
  81.     }
  82.     public function setPoints(int $points): static
  83.     {
  84.         $this->points $points;
  85.         return $this;
  86.     }
  87.     public function getCategory(): ?string
  88.     {
  89.         return $this->category;
  90.     }
  91.     public function setCategory(string $category): static
  92.     {
  93.         $this->category $category;
  94.         return $this;
  95.     }
  96.     public function getFrequency(): ?string
  97.     {
  98.         return $this->frequency;
  99.     }
  100.     public function setFrequency(string $frequency): static
  101.     {
  102.         $this->frequency $frequency;
  103.         return $this;
  104.     }
  105.     public function getMaxPerPeriod(): ?int
  106.     {
  107.         return $this->maxPerPeriod;
  108.     }
  109.     public function setMaxPerPeriod(int $maxPerPeriod): static
  110.     {
  111.         $this->maxPerPeriod $maxPerPeriod;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Submission>
  116.      */
  117.     public function getSubmissions(): Collection
  118.     {
  119.         return $this->submissions;
  120.     }
  121.     public function addSubmission(Submission $submission): static
  122.     {
  123.         if (!$this->submissions->contains($submission)) {
  124.             $this->submissions->add($submission);
  125.             $submission->setActivity($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeSubmission(Submission $submission): static
  130.     {
  131.         if ($this->submissions->removeElement($submission)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($submission->getActivity() === $this) {
  134.                 $submission->setActivity(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139.     /**
  140.      * Check if the activity is daily
  141.      */
  142.     public function isDaily(): bool
  143.     {
  144.         return $this->frequency === 'daily';
  145.     }
  146.     /**
  147.      * Check if the activity is weekly
  148.      */
  149.     public function isWeekly(): bool
  150.     {
  151.         return $this->frequency === 'weekly';
  152.     }
  153.     /**
  154.      * Check if the activity is a one-time activity
  155.      */
  156.     public function isOneTime(): bool
  157.     {
  158.         return $this->frequency === 'once';
  159.     }
  160.     /**
  161.      * Check if the activity has unlimited frequency
  162.      */
  163.     public function isUnlimited(): bool
  164.     {
  165.         return $this->frequency === 'unlimited';
  166.     }
  167.     public function getValidationSchema(): ?array
  168.     {
  169.         return $this->validationSchema;
  170.     }
  171.     public function setValidationSchema(?array $validationSchema): static
  172.     {
  173.         $this->validationSchema $validationSchema;
  174.         return $this;
  175.     }
  176.     public function getEvidenceSchema(): ?array
  177.     {
  178.         return $this->evidenceSchema;
  179.     }
  180.     public function setEvidenceSchema(?array $evidenceSchema): static
  181.     {
  182.         $this->evidenceSchema $evidenceSchema;
  183.         return $this;
  184.     }
  185.     public function getPointCalculationLogic(): ?array
  186.     {
  187.         return $this->pointCalculationLogic;
  188.     }
  189.     public function setPointCalculationLogic(?array $pointCalculationLogic): static
  190.     {
  191.         $this->pointCalculationLogic $pointCalculationLogic;
  192.         return $this;
  193.     }
  194.     public function getValidationRules(): ?array
  195.     {
  196.         return $this->validationRules;
  197.     }
  198.     public function setValidationRules(?array $validationRules): static
  199.     {
  200.         $this->validationRules $validationRules;
  201.         return $this;
  202.     }
  203.     public function isEvidenceRequired(): ?bool
  204.     {
  205.         return $this->evidenceRequired;
  206.     }
  207.     public function setEvidenceRequired(bool $evidenceRequired): static
  208.     {
  209.         $this->evidenceRequired $evidenceRequired;
  210.         return $this;
  211.     }
  212.     public function isTeamActivity(): ?bool
  213.     {
  214.         return $this->teamActivity;
  215.     }
  216.     public function setTeamActivity(bool $teamActivity): static
  217.     {
  218.         $this->teamActivity $teamActivity;
  219.         return $this;
  220.     }
  221.     public function getAdditionalFields(): ?array
  222.     {
  223.         return $this->additionalFields;
  224.     }
  225.     public function setAdditionalFields(?array $additionalFields): static
  226.     {
  227.         $this->additionalFields $additionalFields;
  228.         return $this;
  229.     }
  230.     public function isIsActive(): ?bool
  231.     {
  232.         return $this->isActive;
  233.     }
  234.     public function setIsActive(bool $isActive): static
  235.     {
  236.         $this->isActive $isActive;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return Collection<int, ActivityConfiguration>
  241.      */
  242.     public function getActivityConfigurations(): Collection
  243.     {
  244.         return $this->activityConfigurations;
  245.     }
  246.     public function addActivityConfiguration(ActivityConfiguration $activityConfiguration): static
  247.     {
  248.         if (!$this->activityConfigurations->contains($activityConfiguration)) {
  249.             $this->activityConfigurations->add($activityConfiguration);
  250.             $activityConfiguration->setActivity($this);
  251.         }
  252.         return $this;
  253.     }
  254.     public function removeActivityConfiguration(ActivityConfiguration $activityConfiguration): static
  255.     {
  256.         if ($this->activityConfigurations->removeElement($activityConfiguration)) {
  257.             // set the owning side to null (unless already changed)
  258.             if ($activityConfiguration->getActivity() === $this) {
  259.                 $activityConfiguration->setActivity(null);
  260.             }
  261.         }
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get the validation method for this activity
  266.      */
  267.     public function getValidationMethod(): string
  268.     {
  269.         // Remove the ActivityType dependency
  270.         return $this->teamActivity 'team_leader' 'automatic';
  271.     }
  272.     // Add helper methods from ActivityType
  273.     public function requiresEvidence(): bool
  274.     {
  275.         return !empty($this->evidenceSchema);
  276.     }
  277. }