src/Entity/Flow.php line 25

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Repository\FlowRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\DBAL\Types\Types;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ApiResource(
  13.     operations: [
  14.         new GetCollection(),
  15.         new Get(
  16.             normalizationContext: ['groups' => ['flow:list''flow:view']]
  17.         ),
  18.     ],
  19.     normalizationContext: ['groups' => ['flow:list']]
  20. )]
  21. #[ORM\Entity(repositoryClassFlowRepository::class)]
  22. class Flow
  23. {
  24.     #[ORM\Id]
  25.     #[ORM\GeneratedValue]
  26.     #[ORM\Column]
  27.     #[Groups(['flow:list'])]
  28.     private ?int $id null;
  29.     #[ORM\Column(length255)]
  30.     #[Groups(['flow:list'])]
  31.     private ?string $name null;
  32.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  33.     #[Groups(['flow:list'])]
  34.     private ?string $content null;
  35.     #[ORM\OneToMany(mappedBy'flow'targetEntityAttachment::class)]
  36.     private Collection $attachments;
  37.     #[ORM\OneToMany(mappedBy'flow'targetEntityFlowUser::class)]
  38.     #[Groups(['flow:list'])]
  39.     private Collection $flowUsers;
  40.     #[ORM\ManyToOne(inversedBy'flows')]
  41.     #[Groups(['flow:list'])]
  42.     private ?FlowStep $step null;
  43.     #[ORM\Column]
  44.     #[Groups(['flow:list'])]
  45.     private ?int $rank null;
  46.     public function __construct()
  47.     {
  48.         $this->attachments = new ArrayCollection();
  49.         $this->flowUsers = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName(): ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name): self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getContent(): ?string
  65.     {
  66.         return $this->content;
  67.     }
  68.     public function setContent(?string $content): self
  69.     {
  70.         $this->content $content;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, Attachment>
  75.      */
  76.     public function getAttachments(): Collection
  77.     {
  78.         return $this->attachments;
  79.     }
  80.     public function addAttachment(Attachment $attachment): self
  81.     {
  82.         if (!$this->attachments->contains($attachment)) {
  83.             $this->attachments->add($attachment);
  84.             $attachment->setFlow($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeAttachment(Attachment $attachment): self
  89.     {
  90.         if ($this->attachments->removeElement($attachment)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($attachment->getFlow() === $this) {
  93.                 $attachment->setFlow(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, FlowUser>
  100.      */
  101.     public function getFlowUsers(): Collection
  102.     {
  103.         return $this->flowUsers;
  104.     }
  105.     public function addFlowUser(FlowUser $flowUser): self
  106.     {
  107.         if (!$this->flowUsers->contains($flowUser)) {
  108.             $this->flowUsers->add($flowUser);
  109.             $flowUser->setFlow($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeFlowUser(FlowUser $flowUser): self
  114.     {
  115.         if ($this->flowUsers->removeElement($flowUser)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($flowUser->getFlow() === $this) {
  118.                 $flowUser->setFlow(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getStep(): ?FlowStep
  124.     {
  125.         return $this->step;
  126.     }
  127.     public function setStep(?FlowStep $step): self
  128.     {
  129.         $this->step $step;
  130.         return $this;
  131.     }
  132.     public function getRank(): ?int
  133.     {
  134.         return $this->rank;
  135.     }
  136.     public function setRank(int $rank): self
  137.     {
  138.         $this->rank $rank;
  139.         return $this;
  140.     }
  141. }