<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\SurveyFormStepSurveyFormQuestionRepository")
* @ORM\HasLifecycleCallbacks()
*/
#[ApiResource(
attributes: ['security' => "is_granted('ROLE_USER')"],
normalizationContext: ['groups' => ['sfssfq:read']],
denormalizationContext: ['groups' => ['sfssfq:write']],
collectionOperations: [
'get',
'post' => [
'security' => "is_granted('ROLE_ADMIN')",
],
],
itemOperations: [
'get',
'put' => ['security' => "is_granted('ROLE_ADMIN') or object.owner == user"],
],
)]
class SurveyFormStepSurveyFormQuestion
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var SurveyFormStep
*
* @ORM\ManyToOne(targetEntity="App\Entity\SurveyFormStep", inversedBy="surveyFormQuestions")
* @ORM\JoinColumn(name="survey_form_step_id", referencedColumnName="id", nullable=false)
* @Groups({"sfssfq:read", "sfssfq:write"})
*/
private $surveyFormStep;
/**
* @var SurveyFormQuestion
*
* @ORM\ManyToOne(targetEntity="App\Entity\SurveyFormQuestion", inversedBy="surveyFormSteps")
* @ORM\JoinColumn(name="survey_form_question_id", referencedColumnName="id", nullable=false)
* @Groups({"sfssfq:read", "sfssfq:write"})
*/
private $surveyFormQuestion;
/**
* @ORM\ManyToOne(targetEntity=SurveyCompany::class, inversedBy="surveyQuestionForms")
* @ORM\JoinColumn(name="survey_company_id", referencedColumnName="id", nullable=false)
* @Groups({"sfssfq:read", "sfssfq:write"})
*/
private $surveyCompany;
/**
* @var int
*
* @ORM\Column(type="integer")
* @Assert\Type(type="integer")
* @Groups({"sfssfq:read", "sfssfq:write"})
*/
private $rank;
/**
* @var string
*
* @ORM\Column(type="string", length=2000, nullable=true)
* @Assert\Length(max="2000")
* @Groups({"sfssfq:read", "sfssfq:write"})
*/
private $info;
public function __construct()
{
$this->rank = 0;
}
public function __toString(): string
{
return ($this->getSurveyFormQuestion()) ? $this->getSurveyFormQuestion()->getLabel() : '';
}
public function getId(): ?int
{
return $this->id;
}
public function getRank(): ?int
{
return $this->rank;
}
public function setRank(?int $rank): self
{
$this->rank = $rank;
return $this;
}
public function getInfo(): ?string
{
return $this->info;
}
public function setInfo(?string $info): self
{
$this->info = $info;
return $this;
}
public function getSurveyFormQuestion(): ?SurveyFormQuestion
{
return $this->surveyFormQuestion;
}
public function setSurveyFormQuestion(?SurveyFormQuestion $surveyFormQuestion): self
{
$this->surveyFormQuestion = $surveyFormQuestion;
return $this;
}
public function getSurveyFormStep(): ?SurveyFormStep
{
return $this->surveyFormStep;
}
public function setSurveyFormStep(?SurveyFormStep $surveyFormStep): self
{
$this->surveyFormStep = $surveyFormStep;
return $this;
}
public function getSurveyCompany(): ?SurveyCompany
{
return $this->surveyCompany;
}
public function setSurveyCompany(?SurveyCompany $surveyCompany): self
{
$this->surveyCompany = $surveyCompany;
return $this;
}
}