src/Entity/Checklist.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChecklistRepository;
  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(repositoryClassChecklistRepository::class)]
  9. class Checklist
  10. {
  11.     // Enum values for ChecklistType
  12.     public const TYPE_ONBOARDING 'ONBOARDING';
  13.     public const TYPE_PROJECT 'PROJECT';
  14.     public const TYPE_DEPARTMENT 'DEPARTMENT';
  15.     public const TYPE_OFFBOARDING 'OFFBOARDING';
  16.     public const TYPE_PERMANENT 'PERMANENT';
  17.     // Enum values for ChecklistStatus
  18.     public const STATUS_ACTIVE 'ACTIVE';
  19.     public const STATUS_INACTIVE 'INACTIVE';
  20.     public const STATUS_DRAFT 'DRAFT';
  21.     public const STATUS_COMPLETED 'COMPLETED';
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue]
  24.     #[ORM\Column]
  25.     private ?int $id null;
  26.     #[ORM\Column(length255)]
  27.     private ?string $name null;
  28.     #[ORM\Column(length50)]
  29.     private ?string $type null;
  30.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  31.     private ?\DateTimeInterface $dueDate null;
  32.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  33.     private ?\DateTimeInterface $startDate null;
  34.     #[ORM\Column(length50)]
  35.     private ?string $status null;
  36.     #[ORM\Column]
  37.     private ?bool $isTemplate null;
  38.     #[ORM\Column(nullabletrue)]
  39.     private ?int $position null;
  40.     #[ORM\OneToMany(mappedBy'checklist'targetEntityChecklistTask::class, orphanRemovaltrue)]
  41.     private Collection $tasks;
  42.     #[ORM\ManyToOne(targetEntityself::class, inversedBy'checklistsFromTemplate')]
  43.     private ?self $template null;
  44.     #[ORM\OneToMany(mappedBy'template'targetEntityself::class)]
  45.     private Collection $checklistsFromTemplate;
  46.     #[ORM\ManyToOne(inversedBy'checklists'targetEntityProject::class, cascade: ['persist'])]
  47.     private ?Project $project null;
  48.     #[ORM\ManyToOne(inversedBy'checklists')]
  49.     private ?Department $department null;
  50.     #[ORM\ManyToOne(inversedBy'checklistsAsAssignee')]
  51.     #[ORM\JoinColumn(name"default_assignee_id"referencedColumnName"id"nullabletrueonDelete"SET NULL")]
  52.     private ?User $defaultAssignee null;
  53.     #[ORM\ManyToOne(inversedBy'checklistsAsOwner')]
  54.     #[ORM\JoinColumn(name"owner_id"referencedColumnName"id"nullabletrueonDelete"SET NULL")]
  55.     private ?User $owner null;
  56.     #[ORM\Column(length255nullabletrue)]
  57.     private ?string $mattermostUrl null;
  58.     #[ORM\Column(nullabletrue)]
  59.     private ?bool $isPrivate null;
  60.     #[ORM\ManyToOne(inversedBy'onboardedChecklists')]
  61.     private ?User $onboardUser null;
  62.     #[ORM\OneToMany(mappedBy'checklist'targetEntityChecklistActivity::class)]
  63.     private Collection $checklistActivities;
  64.     #[ORM\OneToMany(mappedBy'checklist'targetEntityChecklistNotification::class)]
  65.     private Collection $checklistNotifications;
  66.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  67.     private ?string $description null;
  68.     public function __construct()
  69.     {
  70.         $this->tasks = new ArrayCollection();
  71.         $this->checklistsFromTemplate = new ArrayCollection();
  72.         $this->checklistActivities = new ArrayCollection();
  73.         $this->checklistNotifications = new ArrayCollection();
  74.     }
  75.     public function getId(): ?int
  76.     {
  77.         return $this->id;
  78.     }
  79.     public function getName(): ?string
  80.     {
  81.         return $this->name;
  82.     }
  83.     public function setName(string $name): self
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     public function getType(): ?string
  89.     {
  90.         return $this->type;
  91.     }
  92.     public function setType(string $type): self
  93.     {
  94.         $this->type $type;
  95.         return $this;
  96.     }
  97.     public function getDueDate(): ?\DateTimeInterface
  98.     {
  99.         return $this->dueDate;
  100.     }
  101.     public function setDueDate(?\DateTimeInterface $dueDate): self
  102.     {
  103.         $this->dueDate $dueDate;
  104.         return $this;
  105.     }
  106.     public function getStartDate(): ?\DateTimeInterface
  107.     {
  108.         return $this->startDate;
  109.     }
  110.     public function setStartDate(?\DateTimeInterface $startDate): self
  111.     {
  112.         $this->startDate $startDate;
  113.         return $this;
  114.     }
  115.     public function getStatus(): ?string
  116.     {
  117.         return $this->status;
  118.     }
  119.     public function setStatus(string $status): self
  120.     {
  121.         $this->status $status;
  122.         return $this;
  123.     }
  124.     public function isIsTemplate(): ?bool
  125.     {
  126.         return $this->isTemplate;
  127.     }
  128.     public function setIsTemplate(bool $isTemplate): self
  129.     {
  130.         $this->isTemplate $isTemplate;
  131.         return $this;
  132.     }
  133.     public function getPosition(): ?int
  134.     {
  135.         return $this->position;
  136.     }
  137.     public function setPosition(?int $position): self
  138.     {
  139.         $this->position $position;
  140.         return $this;
  141.     }
  142.     /**
  143.      * @return Collection<int, ChecklistTask>
  144.      */
  145.     public function getTasks(): Collection
  146.     {
  147.         return $this->tasks;
  148.     }
  149.     public function addTask(ChecklistTask $task): self
  150.     {
  151.         if (!$this->tasks->contains($task)) {
  152.             $this->tasks->add($task);
  153.             $task->setChecklist($this);
  154.         }
  155.         return $this;
  156.     }
  157.     public function removeTask(ChecklistTask $task): self
  158.     {
  159.         if ($this->tasks->removeElement($task)) {
  160.             // set the owning side to null (unless already changed)
  161.             if ($task->getChecklist() === $this) {
  162.                 $task->setChecklist(null);
  163.             }
  164.         }
  165.         return $this;
  166.     }
  167.     public function getTasksStatus(): array
  168.     {
  169.         $tasksStatus['COUNTER'] = ['TO_DO' => 0'TO_VERIFY' => 0'DONE' => 0'TOTAL' => 0];
  170.         $tasksStatus['IS_DONE'] = false;
  171.         $total 0;
  172.         foreach ($this->tasks as $task) {
  173.             if($task->getVisibility() != 'PUBLIC') continue;
  174.             $tasksStatus['COUNTER'][$task->getStatus()]++;
  175.             $total++;
  176.         }
  177.         $tasksStatus['COUNTER']['TOTAL'] = $total;
  178.         $tasksStatus['IS_DONE'] = $tasksStatus['COUNTER']['TOTAL'] > && $tasksStatus['COUNTER']['TOTAL'] == $tasksStatus['COUNTER']['DONE'];
  179.         return $tasksStatus;
  180.     }
  181.     public function getTemplate(): ?self
  182.     {
  183.         return $this->template;
  184.     }
  185.     public function setTemplate(?self $template): self
  186.     {
  187.         $this->template $template;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return Collection<int, self>
  192.      */
  193.     public function getChecklistsFromTemplate(): Collection
  194.     {
  195.         return $this->checklistsFromTemplate;
  196.     }
  197.     public function addChecklistsFromTemplate(self $checklistsFromTemplate): self
  198.     {
  199.         if (!$this->checklistsFromTemplate->contains($checklistsFromTemplate)) {
  200.             $this->checklistsFromTemplate->add($checklistsFromTemplate);
  201.             $checklistsFromTemplate->setTemplate($this);
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeChecklistsFromTemplate(self $checklistsFromTemplate): self
  206.     {
  207.         if ($this->checklistsFromTemplate->removeElement($checklistsFromTemplate)) {
  208.             // set the owning side to null (unless already changed)
  209.             if ($checklistsFromTemplate->getTemplate() === $this) {
  210.                 $checklistsFromTemplate->setTemplate(null);
  211.             }
  212.         }
  213.         return $this;
  214.     }
  215.     public function getProject(): ?Project
  216.     {
  217.         return $this->project;
  218.     }
  219.     public function setProject(?Project $project): self
  220.     {
  221.         $this->project $project;
  222.         return $this;
  223.     }
  224.     public function getDepartment(): ?Department
  225.     {
  226.         return $this->department;
  227.     }
  228.     public function setDepartment(?Department $department): self
  229.     {
  230.         $this->department $department;
  231.         return $this;
  232.     }
  233.     public function getDefaultAssignee(): ?User
  234.     {
  235.         return $this->defaultAssignee;
  236.     }
  237.     public function setDefaultAssignee(?User $defaultAssignee): self
  238.     {
  239.         $this->defaultAssignee $defaultAssignee;
  240.         return $this;
  241.     }
  242.     public function getOwner(): ?User
  243.     {
  244.         return $this->owner;
  245.     }
  246.     public function setOwner(?User $owner): self
  247.     {
  248.         $this->owner $owner;
  249.         return $this;
  250.     }
  251.     public function getMattermostUrl(): ?string
  252.     {
  253.         return $this->mattermostUrl;
  254.     }
  255.     public function setMattermostUrl(?string $mattermostUrl): self
  256.     {
  257.         $this->mattermostUrl $mattermostUrl;
  258.         return $this;
  259.     }
  260.     public function isIsPrivate(): ?bool
  261.     {
  262.         return $this->isPrivate;
  263.     }
  264.     public function setIsPrivate(?bool $isPrivate): self
  265.     {
  266.         $this->isPrivate $isPrivate;
  267.         return $this;
  268.     }
  269.     public function getOnboardUser(): ?User
  270.     {
  271.         return $this->onboardUser;
  272.     }
  273.     public function setOnboardUser(?User $onboardUser): self
  274.     {
  275.         $this->onboardUser $onboardUser;
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection<int, ChecklistActivity>
  280.      */
  281.     public function getChecklistActivities(): Collection
  282.     {
  283.         return $this->checklistActivities;
  284.     }
  285.     public function addChecklistActivity(ChecklistActivity $checklistActivity): self
  286.     {
  287.         if (!$this->checklistActivities->contains($checklistActivity)) {
  288.             $this->checklistActivities->add($checklistActivity);
  289.             $checklistActivity->setChecklist($this);
  290.         }
  291.         return $this;
  292.     }
  293.     public function removeChecklistActivity(ChecklistActivity $checklistActivity): self
  294.     {
  295.         if ($this->checklistActivities->removeElement($checklistActivity)) {
  296.             // set the owning side to null (unless already changed)
  297.             if ($checklistActivity->getChecklist() === $this) {
  298.                 $checklistActivity->setChecklist(null);
  299.             }
  300.         }
  301.         return $this;
  302.     }
  303.     /**
  304.      * @return Collection<int, ChecklistNotification>
  305.      */
  306.     public function getChecklistNotifications(): Collection
  307.     {
  308.         return $this->checklistNotifications;
  309.     }
  310.     public function addChecklistNotification(ChecklistNotification $checklistNotification): self
  311.     {
  312.         if (!$this->checklistNotifications->contains($checklistNotification)) {
  313.             $this->checklistNotifications->add($checklistNotification);
  314.             $checklistNotification->setChecklist($this);
  315.         }
  316.         return $this;
  317.     }
  318.     public function removeChecklistNotification(ChecklistNotification $checklistNotification): self
  319.     {
  320.         if ($this->checklistNotifications->removeElement($checklistNotification)) {
  321.             // set the owning side to null (unless already changed)
  322.             if ($checklistNotification->getChecklist() === $this) {
  323.                 $checklistNotification->setChecklist(null);
  324.             }
  325.         }
  326.         return $this;
  327.     }
  328.     public function getDescription(): ?string
  329.     {
  330.         return $this->description;
  331.     }
  332.     public function setDescription(?string $description): self
  333.     {
  334.         $this->description $description;
  335.         return $this;
  336.     }
  337. }