src/Entity/Questions.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Controller\Action\QuestionsCollectionController;
  6. use App\Controller\Action\QuestionsReadCollectionController;
  7. use App\Repository\QuestionsRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\DBAL\Types\Types;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\Entity(repositoryClassQuestionsRepository::class)]
  14. #[ApiResource(
  15.     operations: [
  16.         new GetCollection(
  17.             uriTemplate'/questions/questions_list',
  18.             controllerQuestionsCollectionController::class,
  19.             readfalse,
  20.             writefalse,
  21.             name'_api_/questions/questions_list'
  22.         )
  23.     ],
  24.     normalizationContext: ['groups' => ['question.get''userQuestion.get']],
  25.     denormalizationContext: ['groups' => ['question.write']]
  26. )]
  27. class Questions
  28. {
  29.     #[ORM\Id]
  30.     #[ORM\GeneratedValue]
  31.     #[ORM\Column]
  32.     #[Groups(['question.get''userQuestion.get'])]
  33.     private ?int $id null;
  34.     #[ORM\Column(length35)]
  35.     #[Groups(['question.get''question.write'])]
  36.     private ?string $category null;
  37.     #[ORM\Column(length255)]
  38.     #[Groups(['question.get''question.write'])]
  39.     private ?string $questionLabel null;
  40.     #[ORM\Column(length210)]
  41.     #[Groups(['question.get''question.write'])]
  42.     private ?string $obligation null;
  43.     #[ORM\Column(length90)]
  44.     #[Groups(['question.get''question.write'])]
  45.     private ?string $documentLabel null;
  46.     #[ORM\Column(typeTypes::TEXT)]
  47.     #[Groups(['question.get''question.write'])]
  48.     private ?string $commentQuestion null;
  49.     #[ORM\ManyToOne]
  50.     private ?Document $document null;
  51.     #[ORM\OneToMany(mappedBy'questions'targetEntitySiteQuestions::class)]
  52.     private Collection $siteQuestions;
  53.     public function __construct()
  54.     {
  55.         $this->siteQuestions = new ArrayCollection();
  56.     }
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.     public function getCategory(): ?string
  62.     {
  63.         return $this->category;
  64.     }
  65.     public function setCategory(string $category): self
  66.     {
  67.         $this->category $category;
  68.         return $this;
  69.     }
  70.     public function getQuestionLabel(): ?string
  71.     {
  72.         return $this->questionLabel;
  73.     }
  74.     public function setQuestionLabel(string $questionLabel): self
  75.     {
  76.         $this->questionLabel $questionLabel;
  77.         return $this;
  78.     }
  79.     public function getObligation(): ?string
  80.     {
  81.         return $this->obligation;
  82.     }
  83.     public function setObligation(string $obligation): self
  84.     {
  85.         $this->obligation $obligation;
  86.         return $this;
  87.     }
  88.     public function getDocumentLabel(): ?string
  89.     {
  90.         return $this->documentLabel;
  91.     }
  92.     public function setDocumentLabel(string $documentLabel): self
  93.     {
  94.         $this->documentLabel $documentLabel;
  95.         return $this;
  96.     }
  97.     public function getCommentQuestion(): ?string
  98.     {
  99.         return $this->commentQuestion;
  100.     }
  101.     public function setCommentQuestion(string $commentQuestion): self
  102.     {
  103.         $this->commentQuestion $commentQuestion;
  104.         return $this;
  105.     }
  106.     public function getDocument(): ?Document
  107.     {
  108.         return $this->document;
  109.     }
  110.     public function setDocument(?Document $document): self
  111.     {
  112.         $this->document $document;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection<int, SiteQuestions>
  117.      */
  118.     public function getSiteQuestions(): Collection
  119.     {
  120.         return $this->siteQuestions;
  121.     }
  122.     public function addSiteQuestion(SiteQuestions $siteQuestion): self
  123.     {
  124.         if (!$this->siteQuestions->contains($siteQuestion)) {
  125.             $this->siteQuestions->add($siteQuestion);
  126.             $siteQuestion->setQuestions($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeSiteQuestion(SiteQuestions $siteQuestion): self
  131.     {
  132.         if ($this->siteQuestions->removeElement($siteQuestion)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($siteQuestion->getQuestions() === $this) {
  135.                 $siteQuestion->setQuestions(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140. }