src/Entity/SurveyFormStepSurveyFormQuestion.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\SurveyFormStepSurveyFormQuestionRepository")
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. #[ApiResource(
  12.     attributes: ['security' => "is_granted('ROLE_USER')"],
  13.     normalizationContext: ['groups' => ['sfssfq:read']],
  14.     denormalizationContext: ['groups' => ['sfssfq:write']],
  15.     collectionOperations: [
  16.         'get',
  17.         'post' => [
  18.             'security' => "is_granted('ROLE_ADMIN')",
  19.         ],
  20.     ],
  21.     itemOperations: [
  22.         'get',
  23.         'put' => ['security' => "is_granted('ROLE_ADMIN') or object.owner == user"],
  24.     ],
  25. )]
  26. class SurveyFormStepSurveyFormQuestion
  27. {
  28.     /**
  29.      * @ORM\Id()
  30.      * @ORM\GeneratedValue()
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @var SurveyFormStep
  36.      *
  37.      * @ORM\ManyToOne(targetEntity="App\Entity\SurveyFormStep", inversedBy="surveyFormQuestions")
  38.      * @ORM\JoinColumn(name="survey_form_step_id", referencedColumnName="id", nullable=false)
  39.      * @Groups({"sfssfq:read", "sfssfq:write"})
  40.      */
  41.     private $surveyFormStep;
  42.     /**
  43.      * @var SurveyFormQuestion
  44.      *
  45.      * @ORM\ManyToOne(targetEntity="App\Entity\SurveyFormQuestion", inversedBy="surveyFormSteps")
  46.      * @ORM\JoinColumn(name="survey_form_question_id", referencedColumnName="id", nullable=false)
  47.      * @Groups({"sfssfq:read", "sfssfq:write"})
  48.      */
  49.     private $surveyFormQuestion;
  50.     /**
  51.      * @ORM\ManyToOne(targetEntity=SurveyCompany::class, inversedBy="surveyQuestionForms")
  52.      * @ORM\JoinColumn(name="survey_company_id", referencedColumnName="id", nullable=false)
  53.      * @Groups({"sfssfq:read", "sfssfq:write"})
  54.      */
  55.     private $surveyCompany;
  56.     /**
  57.      * @var int
  58.      *
  59.      * @ORM\Column(type="integer")
  60.      * @Assert\Type(type="integer")
  61.      * @Groups({"sfssfq:read", "sfssfq:write"})
  62.      */
  63.     private $rank;
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(type="string", length=2000, nullable=true)
  68.      * @Assert\Length(max="2000")
  69.      * @Groups({"sfssfq:read", "sfssfq:write"})
  70.      */
  71.     private $info;
  72.     public function __construct()
  73.     {
  74.         $this->rank 0;
  75.     }
  76.     public function __toString(): string
  77.     {
  78.         return ($this->getSurveyFormQuestion()) ? $this->getSurveyFormQuestion()->getLabel() : '';
  79.     }
  80.     public function getId(): ?int
  81.     {
  82.         return $this->id;
  83.     }
  84.     public function getRank(): ?int
  85.     {
  86.         return $this->rank;
  87.     }
  88.     public function setRank(?int $rank): self
  89.     {
  90.         $this->rank $rank;
  91.         return $this;
  92.     }
  93.     public function getInfo(): ?string
  94.     {
  95.         return $this->info;
  96.     }
  97.     public function setInfo(?string $info): self
  98.     {
  99.         $this->info $info;
  100.         return $this;
  101.     }
  102.     public function getSurveyFormQuestion(): ?SurveyFormQuestion
  103.     {
  104.         return $this->surveyFormQuestion;
  105.     }
  106.     public function setSurveyFormQuestion(?SurveyFormQuestion $surveyFormQuestion): self
  107.     {
  108.         $this->surveyFormQuestion $surveyFormQuestion;
  109.         return $this;
  110.     }
  111.     public function getSurveyFormStep(): ?SurveyFormStep
  112.     {
  113.         return $this->surveyFormStep;
  114.     }
  115.     public function setSurveyFormStep(?SurveyFormStep $surveyFormStep): self
  116.     {
  117.         $this->surveyFormStep $surveyFormStep;
  118.         return $this;
  119.     }
  120.     public function getSurveyCompany(): ?SurveyCompany
  121.     {
  122.         return $this->surveyCompany;
  123.     }
  124.     public function setSurveyCompany(?SurveyCompany $surveyCompany): self
  125.     {
  126.         $this->surveyCompany $surveyCompany;
  127.         return $this;
  128.     }
  129. }