src/Entity/FlowProcess.php line 24

  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\FlowProcessRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. #[ApiResource(
  12.     operations: [
  13.         new GetCollection(),
  14.         new Get(
  15.             normalizationContext: ['groups' => ['flow:list''flow:view']]
  16.         ),
  17.     ],
  18.     normalizationContext: ['groups' => ['flow:list']]
  19. )]
  20. #[ORM\Entity(repositoryClassFlowProcessRepository::class)]
  21. class FlowProcess
  22. {
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     #[Groups(['flow:list'])]
  27.     private ?int $id null;
  28.     #[ORM\Column(length255)]
  29.     #[Groups(['flow:list'])]
  30.     private ?string $name null;
  31.     #[ORM\OneToMany(mappedBy'flowProcess'targetEntityFlowStep::class)]
  32.     private Collection $step;
  33.     public function __construct()
  34.     {
  35.         $this->step = new ArrayCollection();
  36.     }
  37.     public function getId(): ?int
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getName(): ?string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function setName(string $name): self
  46.     {
  47.         $this->name $name;
  48.         return $this;
  49.     }
  50.     /**
  51.      * @return Collection<int, FlowStep>
  52.      */
  53.     public function getStep(): Collection
  54.     {
  55.         return $this->step;
  56.     }
  57.     public function addStep(FlowStep $step): self
  58.     {
  59.         if (!$this->step->contains($step)) {
  60.             $this->step->add($step);
  61.             $step->setFlowProcess($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function removeStep(FlowStep $step): self
  66.     {
  67.         if ($this->step->removeElement($step)) {
  68.             // set the owning side to null (unless already changed)
  69.             if ($step->getFlowProcess() === $this) {
  70.                 $step->setFlowProcess(null);
  71.             }
  72.         }
  73.         return $this;
  74.     }
  75. }