<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiFilter;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\SurveyTriggerRepository;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Interfaces\ContainerMappedInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_OPERATOR')"},
* normalizationContext={"groups"={"SurveyTrigger:Read"}, "skip_null_values"=false},
* denormalizationContext={"groups"={"SurveyTrigger:Write"}},
* collectionOperations={
* "get",
* "post"
* },
* itemOperations={
* "get",
* "put",
* "patch",
* "delete"
* }
* )
* @ApiFilter(SearchFilter::class, properties={"container.id": "exact", "survey.id": "exact", "triggerType": "exact", "url": "partial"})
* @ApiFilter(BooleanFilter::class, properties={"survey.isActive"})
* @ApiFilter(OrderFilter::class, properties={"id", "survey", "url", "createdAt"})
* @ORM\Entity(repositoryClass=SurveyTriggerRepository::class)
*/
class SurveyTrigger implements ContainerMappedInterface
{
/**
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"SurveyTrigger:Read", "Survey:Read"})
*/
private $id;
/**
* @ORM\Column(type="string", length=128)
* @ApiProperty(
* attributes={
* "openapi_context"={
* "type"="string",
* "enum"={self::SURVEYTRIGGERTYPE_ON_JOIN_URL, self::SURVEYTRIGGERTYPE_ON_LEAVE_URL, self::SURVEYTRIGGERTYPE_ON_TASK_END, self::SURVEYTRIGGERTYPE_ON_EXAM_END}
* }
* }
* )
*
* @Assert\Choice({self::SURVEYTRIGGERTYPE_ON_JOIN_URL, self::SURVEYTRIGGERTYPE_ON_LEAVE_URL, self::SURVEYTRIGGERTYPE_ON_TASK_END, self::SURVEYTRIGGERTYPE_ON_EXAM_END})
* @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
*/
private $triggerType;
public const SURVEYTRIGGERTYPE_ON_JOIN_URL = "ON_JOIN_URL";
public const SURVEYTRIGGERTYPE_ON_LEAVE_URL = "ON_LEAVE_URL";
public const SURVEYTRIGGERTYPE_ON_TASK_END = "ON_TASK_END";
public const SURVEYTRIGGERTYPE_ON_EXAM_END = "ON_EXAM_END";
/**
* @ORM\ManyToOne(targetEntity=Survey::class, inversedBy="surveyTriggers")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write"})
*/
private $survey;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
*/
private $url;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
*/
private $delay;
/**
* @ORM\ManyToOne(targetEntity=Container::class)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"SurveyTrigger:Write", "Survey:Write"})
*/
private $container;
/**
* @ORM\Column(type="string", length=32, nullable=true)
* @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
*/
private $displayType;
public const SURVEYTRIGGERDISPLAYTYPE_BOTTOM = "BOTTOM";
public const SURVEYTRIGGERDISPLAYTYPE_TOP = "TOP";
public const SURVEYTRIGGERDISPLAYTYPE_POPUP = "POPUP";
/**
* @ORM\ManyToOne(targetEntity=ElTask::class, inversedBy="surveyTriggers")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
* @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
*/
private $elTask;
/**
* @ORM\ManyToOne(targetEntity=ElExam::class, inversedBy="surveyTriggers")
* @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
* @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
*/
private $elExam;
public function getId(): ?int
{
return $this->id;
}
public function getTriggerType(): ?string
{
return $this->triggerType;
}
public function setTriggerType(string $triggerType): self
{
$this->triggerType = $triggerType;
return $this;
}
public function getSurvey(): ?Survey
{
return $this->survey;
}
public function setSurvey(?Survey $survey): self
{
$this->survey = $survey;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function getDelay(): ?int
{
return $this->delay;
}
public function setDelay(?int $delay): self
{
$this->delay = $delay;
return $this;
}
public function getContainer(): ?Container
{
return $this->container;
}
public function setContainer(?Container $container): self
{
$this->container = $container;
return $this;
}
public function getDisplayType(): ?string
{
return $this->displayType;
}
public function setDisplayType(?string $displayType): self
{
$this->displayType = $displayType;
return $this;
}
public function getElTask(): ?ElTask
{
return $this->elTask;
}
public function setElTask(?ElTask $elTask): self
{
$this->elTask = $elTask;
return $this;
}
public function getElExam(): ?ElExam
{
return $this->elExam;
}
public function setElExam(?ElExam $elExam): self
{
$this->elExam = $elExam;
return $this;
}
}