src/Entity/SurveyContributionStep.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Fluoresce\ValidateEmbedded\Constraints as FluoresceAssert;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\SurveyContributionStepRepository")
  11.  */
  12. class SurveyContributionStep
  13. {
  14.     /**
  15.      * @ORM\Id()
  16.      * @ORM\GeneratedValue()
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @var SurveyContribution
  22.      *
  23.      * @ORM\ManyToOne(targetEntity="App\Entity\SurveyContribution", inversedBy="contributionSteps")
  24.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  25.      * @Assert\NotNull()
  26.      */
  27.     private $contribution;
  28.     /**
  29.      * @var SurveyFormStep
  30.      *
  31.      * @ORM\ManyToOne(targetEntity="App\Entity\SurveyFormStep")
  32.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  33.      * @Assert\NotNull()
  34.      */
  35.     private $formStep;
  36.     /**
  37.      * @var ArrayCollection
  38.      *
  39.      * @ORM\OneToMany(targetEntity="App\Entity\SurveyContributionQuestion", cascade={"persist"}, mappedBy="contributionStep")
  40.      * @FluoresceAssert\Validate(embeddedGroups={"Default"})
  41.      * @Groups({"surveyContribution:read"})
  42.      */
  43.     private $contributionQuestions;
  44.     public function __construct()
  45.     {
  46.         $this->contributionQuestions = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getContribution(): ?SurveyContribution
  53.     {
  54.         return $this->contribution;
  55.     }
  56.     public function setContribution(?SurveyContribution $contribution): self
  57.     {
  58.         $this->contribution $contribution;
  59.         return $this;
  60.     }
  61.     public function getFormStep(): ?SurveyFormStep
  62.     {
  63.         return $this->formStep;
  64.     }
  65.     public function setFormStep(?SurveyFormStep $formStep): self
  66.     {
  67.         $this->formStep $formStep;
  68.         return $this;
  69.     }
  70.     /**
  71.      * @return Collection|SurveyContributionQuestion[]
  72.      */
  73.     public function getContributionQuestions(): Collection
  74.     {
  75.         return $this->contributionQuestions;
  76.     }
  77.     public function addContributionQuestion(SurveyContributionQuestion $contributionQuestion): self
  78.     {
  79.         if (!$this->contributionQuestions->contains($contributionQuestion)) {
  80.             $this->contributionQuestions[] = $contributionQuestion;
  81.             $contributionQuestion->setContributionStep($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function removeContributionQuestion(SurveyContributionQuestion $contributionQuestion): self
  86.     {
  87.         if ($this->contributionQuestions->contains($contributionQuestion)) {
  88.             $this->contributionQuestions->removeElement($contributionQuestion);
  89.             // set the owning side to null (unless already changed)
  90.             if ($contributionQuestion->getContributionStep() === $this) {
  91.                 $contributionQuestion->setContributionStep(null);
  92.             }
  93.         }
  94.         return $this;
  95.     }
  96. }