src/Entity/PipelineIdentiteVisuelleMaj.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\PipelineIdentiteVisuelleMajStatus;
  4. use App\Repository\PipelineIdentiteVisuelleMajRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassPipelineIdentiteVisuelleMajRepository::class)]
  9. class PipelineIdentiteVisuelleMaj
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private ?int $id null;
  15.     #[ORM\ManyToOne(targetEntityAccountingFirm::class)]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private ?AccountingFirm $accountingFirm null;
  18.     #[ORM\Column(type'string'length30)]
  19.     private string $status PipelineIdentiteVisuelleMajStatus::OPEN;
  20.     #[ORM\Column(type'string'length255nullabletrue)]
  21.     private ?string $trelloCardId null;
  22.     #[ORM\Column(type'datetime_immutable')]
  23.     private \DateTimeImmutable $createdAt;
  24.     #[ORM\Column(type'datetime_immutable')]
  25.     private \DateTimeImmutable $updatedAt;
  26.     #[ORM\OneToMany(mappedBy'pipeline'targetEntityPipelineIdentiteVisuelleMajItem::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  27.     private Collection $items;
  28.     public function __construct()
  29.     {
  30.         $this->items = new ArrayCollection();
  31.         $now = new \DateTimeImmutable();
  32.         $this->createdAt $now;
  33.         $this->updatedAt $now;
  34.     }
  35.     public function getId(): ?int { return $this->id; }
  36.     public function getAccountingFirm(): ?AccountingFirm { return $this->accountingFirm; }
  37.     public function setAccountingFirm(AccountingFirm $firm): self $this->accountingFirm $firm; return $this; }
  38.     public function getStatus(): string { return $this->status; }
  39.     public function setStatus(string $status): self $this->status $status; return $this; }
  40.     public function getTrelloCardId(): ?string { return $this->trelloCardId; }
  41.     public function setTrelloCardId(?string $id): self $this->trelloCardId $id; return $this; }
  42.     public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; }
  43.     public function setCreatedAt(\DateTimeImmutable $dt): self $this->createdAt $dt; return $this; }
  44.     public function getUpdatedAt(): \DateTimeImmutable { return $this->updatedAt; }
  45.     public function setUpdatedAt(\DateTimeImmutable $dt): self $this->updatedAt $dt; return $this; }
  46.     /** @return Collection<int, PipelineIdentiteVisuelleMajItem> */
  47.     public function getItems(): Collection { return $this->items; }
  48.     public function addItem(PipelineIdentiteVisuelleMajItem $item): self
  49.     {
  50.         if (!$this->items->contains($item)) {
  51.             $this->items->add($item);
  52.             $item->setPipeline($this);
  53.         }
  54.         return $this;
  55.     }
  56.     public function removeItem(PipelineIdentiteVisuelleMajItem $item): self
  57.     {
  58.         if ($this->items->removeElement($item)) {
  59.             if ($item->getPipeline() === $this) {
  60.                 $item->setPipeline(null);
  61.             }
  62.         }
  63.         return $this;
  64.     }
  65.     public function refreshGlobalStatus(): void
  66.     {
  67.         foreach ($this->items as $item) {
  68.             if ($item->getStatus() !== \App\Enum\PipelineIdentiteVisuelleMajItemStatus::VALIDATED) {
  69.                 $this->status PipelineIdentiteVisuelleMajStatus::OPEN;
  70.                 return;
  71.             }
  72.         }
  73.         $this->status PipelineIdentiteVisuelleMajStatus::DONE;
  74.     }
  75. }