<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Controller\Action\QuestionsCollectionController;
use App\Controller\Action\QuestionsReadCollectionController;
use App\Repository\QuestionsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: QuestionsRepository::class)]
#[ApiResource(
operations: [
new GetCollection(
uriTemplate: '/questions/questions_list',
controller: QuestionsCollectionController::class,
read: false,
write: false,
name: '_api_/questions/questions_list'
)
],
normalizationContext: ['groups' => ['question.get', 'userQuestion.get']],
denormalizationContext: ['groups' => ['question.write']]
)]
class Questions
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['question.get', 'userQuestion.get'])]
private ?int $id = null;
#[ORM\Column(length: 35)]
#[Groups(['question.get', 'question.write'])]
private ?string $category = null;
#[ORM\Column(length: 255)]
#[Groups(['question.get', 'question.write'])]
private ?string $questionLabel = null;
#[ORM\Column(length: 210)]
#[Groups(['question.get', 'question.write'])]
private ?string $obligation = null;
#[ORM\Column(length: 90)]
#[Groups(['question.get', 'question.write'])]
private ?string $documentLabel = null;
#[ORM\Column(type: Types::TEXT)]
#[Groups(['question.get', 'question.write'])]
private ?string $commentQuestion = null;
#[ORM\ManyToOne]
private ?Document $document = null;
#[ORM\OneToMany(mappedBy: 'questions', targetEntity: SiteQuestions::class)]
private Collection $siteQuestions;
public function __construct()
{
$this->siteQuestions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
public function getQuestionLabel(): ?string
{
return $this->questionLabel;
}
public function setQuestionLabel(string $questionLabel): self
{
$this->questionLabel = $questionLabel;
return $this;
}
public function getObligation(): ?string
{
return $this->obligation;
}
public function setObligation(string $obligation): self
{
$this->obligation = $obligation;
return $this;
}
public function getDocumentLabel(): ?string
{
return $this->documentLabel;
}
public function setDocumentLabel(string $documentLabel): self
{
$this->documentLabel = $documentLabel;
return $this;
}
public function getCommentQuestion(): ?string
{
return $this->commentQuestion;
}
public function setCommentQuestion(string $commentQuestion): self
{
$this->commentQuestion = $commentQuestion;
return $this;
}
public function getDocument(): ?Document
{
return $this->document;
}
public function setDocument(?Document $document): self
{
$this->document = $document;
return $this;
}
/**
* @return Collection<int, SiteQuestions>
*/
public function getSiteQuestions(): Collection
{
return $this->siteQuestions;
}
public function addSiteQuestion(SiteQuestions $siteQuestion): self
{
if (!$this->siteQuestions->contains($siteQuestion)) {
$this->siteQuestions->add($siteQuestion);
$siteQuestion->setQuestions($this);
}
return $this;
}
public function removeSiteQuestion(SiteQuestions $siteQuestion): self
{
if ($this->siteQuestions->removeElement($siteQuestion)) {
// set the owning side to null (unless already changed)
if ($siteQuestion->getQuestions() === $this) {
$siteQuestion->setQuestions(null);
}
}
return $this;
}
}