src/Entity/FlowStep.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\FlowStepRepository;
  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. #[ORM\Entity(repositoryClassFlowStepRepository::class)]
  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. class FlowStep
  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\Column(nullabletrue)]
  32.     private array $users = [];
  33.     #[ORM\OneToMany(mappedBy'step'targetEntityFlowAction::class)]
  34.     #[Groups(['flow:list'])]
  35.     private Collection $flowActions;
  36.     #[ORM\OneToMany(mappedBy'step'targetEntityFlow::class)]
  37.     #[Groups(['flow:list'])]
  38.     private Collection $flows;
  39.     #[ORM\Column]
  40.     #[Groups(['flow:list'])]
  41.     private ?int $rank null;
  42.     #[ORM\ManyToOne(inversedBy'step')]
  43.     #[ORM\JoinColumn(nullablefalse)]
  44.     #[Groups(['flow:list'])]
  45.     private ?FlowProcess $flowProcess null;
  46.     public function __construct()
  47.     {
  48.         $this->flowActions = new ArrayCollection();
  49.         $this->flows = 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 getUsers(): array
  65.     {
  66.         return $this->users;
  67.     }
  68.     public function setUsers(?array $users): self
  69.     {
  70.         $this->users $users;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection<int, FlowAction>
  75.      */
  76.     public function getFlowActions(): Collection
  77.     {
  78.         return $this->flowActions;
  79.     }
  80.     public function addFlowAction(FlowAction $flowAction): self
  81.     {
  82.         if (!$this->flowActions->contains($flowAction)) {
  83.             $this->flowActions->add($flowAction);
  84.             $flowAction->setStep($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeFlowAction(FlowAction $flowAction): self
  89.     {
  90.         if ($this->flowActions->removeElement($flowAction)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($flowAction->getStep() === $this) {
  93.                 $flowAction->setStep(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, Flow>
  100.      */
  101.     public function getFlows(): Collection
  102.     {
  103.         return $this->flows;
  104.     }
  105.     public function addFlow(Flow $flow): self
  106.     {
  107.         if (!$this->flows->contains($flow)) {
  108.             $this->flows->add($flow);
  109.             $flow->setStep($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeFlow(Flow $flow): self
  114.     {
  115.         if ($this->flows->removeElement($flow)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($flow->getStep() === $this) {
  118.                 $flow->setStep(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getRank(): ?int
  124.     {
  125.         return $this->rank;
  126.     }
  127.     public function setRank(int $rank): self
  128.     {
  129.         $this->rank $rank;
  130.         return $this;
  131.     }
  132.     public function getFlowProcess(): ?FlowProcess
  133.     {
  134.         return $this->flowProcess;
  135.     }
  136.     public function setFlowProcess(?FlowProcess $flowProcess): self
  137.     {
  138.         $this->flowProcess $flowProcess;
  139.         return $this;
  140.     }
  141. }