<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\GroupFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Repository\SurveyConfigRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=SurveyConfigRepository::class)
* @ApiResource(
* normalizationContext={
* "groups"={"survey_config:read"}
* },
* denormalizationContext={
* "groups"={"survey_config:write"}
* },
* collectionOperations={
* "get",
* "post"={
* "security"="is_granted('ROLE_ADMIN')"
* },
* },
* itemOperations={
* "get"={
* "security"="is_granted('ROLE_USER')"
* },
* "delete"={
* "security"="is_granted('ROLE_ADMIN')"
* },
* "patch"={
* "security"="is_granted('ROLE_ADMIN')"
* },
* }
* )
* @ApiFilter(SearchFilter::class)
* @ORM\HasLifecycleCallbacks
* @ApiFilter(GroupFilter::class, arguments={
* "parameterName": "groups",
* "overrideDefaultGroups": true,
* "whitelist": {"survey_config_list"}
* })
* @ApiFilter(PropertyFilter::class,
* arguments={
* "parameterName"="fields",
* "overrideDefaultProperties"=true
* }
* )
*/
class SurveyConfig
{
const GLOBAL_TYPE = "global";
const RECOMMENDED_OBJECTIVES = "recommended_objectives";
const TYPES = [
self::RECOMMENDED_OBJECTIVES,
];
const INTERVALLE_1 = "intervalle_1"; // Tranche de [0% - 25%[
const INTERVALLE_2 = "intervalle_2"; // Tranche de [25% - 50%[
const INTERVALLE_3 = "intervalle_3"; // Tranche de [50% - 75%[
const INTERVALLE_4 = "intervalle_4"; // Tranche de [75% - 100%]
const SUBTYPES = [
self::INTERVALLE_1,
self::INTERVALLE_2,
self::INTERVALLE_3,
self::INTERVALLE_4,
];
const INTERVALLES = [
self::INTERVALLE_1,
self::INTERVALLE_2,
self::INTERVALLE_3,
self::INTERVALLE_4,
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"survey:read", "survey_config:read", "question:read", "survey_config_list"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Survey::class, inversedBy="configs")
* @ORM\JoinColumn(nullable=false)
* @Groups({"survey_config:read", "question:read"})
*/
private $survey;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"survey:read", "survey_config:read", "question:read", "survey_config_list"})
* @Assert\Choice(choices=self::TYPES)
*/
private $type = self::GLOBAL_TYPE;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"survey:read", "survey_config:read", "question:read", "survey_config_list"})
* @Assert\Choice(choices=self::SUBTYPES)
*/
private $subType;
/**
* @ORM\ManyToOne(targetEntity=TvTag::class)
* @Groups({"survey_config:read", "question:read", "survey_config_list"})
*/
private $tvTag = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"survey_config:read", "survey_config:write", "question:read"})
*/
private $value = null;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": 1})
* @Groups({"survey:read", "survey_config:read", "question:read", "survey_config_list"})
*/
private $active = true;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime")
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
public function getId(): ?int
{
return $this->id;
}
public function getSurvey(): ?Survey
{
return $this->survey;
}
public function setSurvey(?Survey $survey): self
{
$this->survey = $survey;
return $this;
}
public function getTvTag(): ?TvTag
{
return $this->tvTag;
}
public function setTvTag(?TvTag $tvTag): self
{
$this->tvTag = $tvTag;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(?bool $active): self
{
$this->active = $active;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getSubType(): ?string
{
return $this->subType;
}
public function setSubType(?string $subType): self
{
$this->subType = $subType;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): self
{
$this->value = $value;
return $this;
}
}