src/Entity/SurveyTrigger.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use ApiPlatform\Core\Annotation\ApiFilter;
  5. use App\Entity\Traits\TimestampableEntity;
  6. use App\Repository\SurveyTriggerRepository;
  7. use ApiPlatform\Core\Annotation\ApiProperty;
  8. use ApiPlatform\Core\Annotation\ApiResource;
  9. use App\Entity\Interfaces\ContainerMappedInterface;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  13. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  14. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  15. /**
  16.  * @ApiResource(
  17.  *      attributes={"security"="is_granted('ROLE_OPERATOR')"},
  18.  *      normalizationContext={"groups"={"SurveyTrigger:Read"}, "skip_null_values"=false},
  19.  *      denormalizationContext={"groups"={"SurveyTrigger:Write"}},
  20.  *      collectionOperations={
  21.  *          "get",
  22.  *          "post"
  23.  *      },
  24.  *      itemOperations={
  25.  *          "get",
  26.  *          "put",
  27.  *          "patch",
  28.  *          "delete"
  29.  *     }
  30.  * )
  31.  * @ApiFilter(SearchFilter::class, properties={"container.id": "exact", "survey.id": "exact", "triggerType": "exact", "url": "partial"})
  32.  * @ApiFilter(BooleanFilter::class, properties={"survey.isActive"})
  33.  * @ApiFilter(OrderFilter::class, properties={"id", "survey", "url", "createdAt"})
  34.  * @ORM\Entity(repositoryClass=SurveyTriggerRepository::class)
  35.  */
  36. class SurveyTrigger implements ContainerMappedInterface
  37. {
  38.     /**
  39.      * Hook timestampable behavior
  40.      * updates createdAt, updatedAt fields
  41.      */
  42.     use TimestampableEntity;
  43.     /**
  44.      * @ORM\Id
  45.      * @ORM\GeneratedValue
  46.      * @ORM\Column(type="integer")
  47.      * @Groups({"SurveyTrigger:Read", "Survey:Read"})
  48.      */
  49.     private $id;
  50.     /**
  51.      * @ORM\Column(type="string", length=128)
  52.      * @ApiProperty(
  53.      *     attributes={
  54.      *         "openapi_context"={
  55.      *             "type"="string",
  56.      *             "enum"={self::SURVEYTRIGGERTYPE_ON_JOIN_URL, self::SURVEYTRIGGERTYPE_ON_LEAVE_URL, self::SURVEYTRIGGERTYPE_ON_TASK_END, self::SURVEYTRIGGERTYPE_ON_EXAM_END}
  57.      *         }
  58.      *     }
  59.      * )
  60.      *
  61.      * @Assert\Choice({self::SURVEYTRIGGERTYPE_ON_JOIN_URL, self::SURVEYTRIGGERTYPE_ON_LEAVE_URL, self::SURVEYTRIGGERTYPE_ON_TASK_END, self::SURVEYTRIGGERTYPE_ON_EXAM_END})
  62.      * @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
  63.      */
  64.     private $triggerType;
  65.     public const SURVEYTRIGGERTYPE_ON_JOIN_URL "ON_JOIN_URL";
  66.     public const SURVEYTRIGGERTYPE_ON_LEAVE_URL "ON_LEAVE_URL";
  67.     public const SURVEYTRIGGERTYPE_ON_TASK_END "ON_TASK_END";
  68.     public const SURVEYTRIGGERTYPE_ON_EXAM_END "ON_EXAM_END";
  69.     /**
  70.      * @ORM\ManyToOne(targetEntity=Survey::class, inversedBy="surveyTriggers")
  71.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  72.      * @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write"})
  73.      */
  74.     private $survey;
  75.     /**
  76.      * @ORM\Column(type="string", length=255, nullable=true)
  77.      * @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
  78.      */
  79.     private $url;
  80.     /**
  81.      * @ORM\Column(type="integer", nullable=true)
  82.      * @Groups({"SurveyTrigger:Read", "SurveyTrigger:Write", "Survey:Read", "Survey:Write"})
  83.      */
  84.     private $delay;
  85.     /**
  86.      * @ORM\ManyToOne(targetEntity=Container::class)
  87.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  88.      * @Groups({"SurveyTrigger:Write", "Survey:Write"})
  89.      */
  90.     private $container;
  91.     /**
  92.      * @ORM\Column(type="string", length=32, nullable=true)
  93.      * @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
  94.      */
  95.     private $displayType;
  96.     public const SURVEYTRIGGERDISPLAYTYPE_BOTTOM "BOTTOM";
  97.     public const SURVEYTRIGGERDISPLAYTYPE_TOP "TOP";
  98.     public const SURVEYTRIGGERDISPLAYTYPE_POPUP "POPUP";
  99.     /**
  100.      * @ORM\ManyToOne(targetEntity=ElTask::class, inversedBy="surveyTriggers")
  101.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  102.      * @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
  103.      */
  104.     private $elTask;
  105.     /**
  106.      * @ORM\ManyToOne(targetEntity=ElExam::class, inversedBy="surveyTriggers")
  107.      * @ORM\JoinColumn(nullable=true, onDelete="CASCADE")
  108.      * @Groups({"SurveyTrigger:Write", "Survey:Write", "Survey:Read"})
  109.      */
  110.     private $elExam;
  111.     public function getId(): ?int
  112.     {
  113.         return $this->id;
  114.     }
  115.     public function getTriggerType(): ?string
  116.     {
  117.         return $this->triggerType;
  118.     }
  119.     public function setTriggerType(string $triggerType): self
  120.     {
  121.         $this->triggerType $triggerType;
  122.         return $this;
  123.     }
  124.     public function getSurvey(): ?Survey
  125.     {
  126.         return $this->survey;
  127.     }
  128.     public function setSurvey(?Survey $survey): self
  129.     {
  130.         $this->survey $survey;
  131.         return $this;
  132.     }
  133.     public function getUrl(): ?string
  134.     {
  135.         return $this->url;
  136.     }
  137.     public function setUrl(?string $url): self
  138.     {
  139.         $this->url $url;
  140.         return $this;
  141.     }
  142.     public function getDelay(): ?int
  143.     {
  144.         return $this->delay;
  145.     }
  146.     public function setDelay(?int $delay): self
  147.     {
  148.         $this->delay $delay;
  149.         return $this;
  150.     }
  151.     public function getContainer(): ?Container
  152.     {
  153.         return $this->container;
  154.     }
  155.     public function setContainer(?Container $container): self
  156.     {
  157.         $this->container $container;
  158.         return $this;
  159.     }
  160.     public function getDisplayType(): ?string
  161.     {
  162.         return $this->displayType;
  163.     }
  164.     public function setDisplayType(?string $displayType): self
  165.     {
  166.         $this->displayType $displayType;
  167.         return $this;
  168.     }
  169.     public function getElTask(): ?ElTask
  170.     {
  171.         return $this->elTask;
  172.     }
  173.     public function setElTask(?ElTask $elTask): self
  174.     {
  175.         $this->elTask $elTask;
  176.         return $this;
  177.     }
  178.     public function getElExam(): ?ElExam
  179.     {
  180.         return $this->elExam;
  181.     }
  182.     public function setElExam(?ElExam $elExam): self
  183.     {
  184.         $this->elExam $elExam;
  185.         return $this;
  186.     }
  187. }