src/Entity/Survey/Survey.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Survey;
  3. use App\Entity\PrimaryIdTrait;
  4. use App\Entity\User\User;
  5. use App\Repository\Survey\SurveyRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Timestampable\Traits\TimestampableEntity;
  10. use Symfony\Component\Cache\Adapter\FilesystemAdapter;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\Entity(repositoryClassSurveyRepository::class)]
  14. class Survey
  15. {
  16.     public const ROUTE_NAME_CREATE 'SURVEY_CREATE';
  17.     public const ROUTE_NAME_EDIT 'SURVEY_EDIT';
  18.     public const ROUTE_NAME_DETAIL 'SURVEY_DETAIL';
  19.     public const ROUTE_NAME_DELETE 'SURVEY_DELETE';
  20.     public const OPEN 1;
  21.     public const CLOSE 0;
  22.     public const TYPE_PRIVATE 0;
  23.     public const TYPE_PUBLIC 1;
  24.     public const REFRESH_ENABLED 1;
  25.     public const REFRESH_DISABLED 0;
  26.     public const STATUS = [
  27.         self::OPEN => 'survey.status.open',
  28.         self::CLOSE => 'survey.status.close',
  29.     ];
  30.     public const TYPES = [
  31.         self::TYPE_PUBLIC => 'survey.type.public',
  32.         self::TYPE_PRIVATE => 'survey.type.private'
  33.     ];
  34.     public const REFRESHES = [
  35.       self::REFRESH_ENABLED => 'survey.refresh.enabled',
  36.       self::REFRESH_DISABLED => 'survey.refresh.disabled'
  37.     ];
  38.     public const RESULT_MYSELF_YES true;
  39.     public const RESULT_MYSELF_NO false;
  40.     public const RESULT_MYSELF = [
  41.         self::RESULT_MYSELF_YES => 'survey.resultMyself.yes',
  42.         self::RESULT_MYSELF_NO => 'survey.resultMyself.no'
  43.     ];
  44.     public const NOTIFICATION_DAY_MONDAY 1;
  45.     public const NOTIFICATION_DAY_TUESDAY 2;
  46.     public const NOTIFICATION_DAY_WEDNESDAY 3;
  47.     public const NOTIFICATION_DAY_THURSDAY 4;
  48.     public const NOTIFICATION_DAY_FRIDAY 5;
  49.     public const NOTIFICATION_DAY_SATURDAY 6;
  50.     public const NOTIFICATION_DAY_SUNDAY 7;
  51.     public const NOTIFICATION_DAYS = [
  52.         self::NOTIFICATION_DAY_MONDAY => 'survey.notificationDays.monday',
  53.         self::NOTIFICATION_DAY_TUESDAY => 'survey.notificationDays.tuesday',
  54.         self::NOTIFICATION_DAY_WEDNESDAY => 'survey.notificationDays.wednesday',
  55.         self::NOTIFICATION_DAY_THURSDAY => 'survey.notificationDays.thursday',
  56.         self::NOTIFICATION_DAY_FRIDAY => 'survey.notificationDays.friday',
  57.         self::NOTIFICATION_DAY_SATURDAY => 'survey.notificationDays.saturday',
  58.         self::NOTIFICATION_DAY_SUNDAY => 'survey.notificationDays.sunday',
  59.     ];
  60.     public const NOTIFICATION_AFTER_EACH_YES true;
  61.     public const NOTIFICATION_AFTER_EACH_NO false;
  62.     public const NOTIFICATION_AFTER_EACH = [
  63.         self::NOTIFICATION_AFTER_EACH_NO => 'survey.notificationAfterEach.no',
  64.         self::NOTIFICATION_AFTER_EACH_YES => 'survey.notificationAfterEach.yes'
  65.     ];
  66.     public const NOTIFICATION_APPOINTED_TIME_YES true;
  67.     public const NOTIFICATION_APPOINTED_TIME_NO false;
  68.     public const NOTIFICATION_APPOINTED_TIME = [
  69.         self::NOTIFICATION_APPOINTED_TIME_NO => 'survey.notificationAppointedTime.no',
  70.         self::NOTIFICATION_APPOINTED_TIME_YES => 'survey.notificationAppointedTime.yes'
  71.     ];
  72.     public const TIMER_NO false;
  73.     public const TIMER_YES true;
  74.     public const TIMER = [
  75.         self::TIMER_NO => 'survey.timer.no',
  76.         self::TIMER_YES => 'survey.timer.yes'
  77.     ];
  78.     use PrimaryIdTrait;
  79.     use TimestampableEntity;
  80.     #[ORM\Column(type'string'uniquetrue)]
  81.     private string $uri;
  82.     #[ORM\Column(type'string')]
  83.     #[Groups(['survey'])]
  84.     private string $title;
  85.     #[ORM\Column(type'text'nullabletrue)]
  86.     #[Groups(['survey'])]
  87.     private ?string $description;
  88.     #[ORM\Column(type'integer')]
  89.     private int $status;
  90.     #[ORM\Column(type'integer')]
  91.     #[Groups(['survey''childrenQuestions'])]
  92.     private int $type;
  93.     #[ORM\Column(type'datetime'nullabletrue)]
  94.     protected ?\DateTime $validStart;
  95.     #[ORM\Column(type'datetime'nullabletrue)]
  96.     protected ?\DateTime $validEnd;
  97.     #[ORM\OneToMany(targetEntity'App\Entity\Survey\SurveyQuestion'mappedBy'survey'cascade: ['persist''remove'], orphanRemovaltrue)]
  98.     #[ORM\OrderBy(['sort' => 'ASC'])]
  99.     #[Groups(['survey'])]
  100.     public $surveyQuestion;
  101.     #[ORM\OneToMany(targetEntity'App\Entity\Survey\SurveyResult'mappedBy'survey'cascade: ['remove'])]
  102.     #[ORM\OrderBy(['createdAt' => 'DESC'])]
  103.     public $surveyResult;
  104.     /**
  105.      * @var User
  106.      */
  107.     #[ORM\ManyToOne(targetEntity'App\Entity\User\User'inversedBy'survey')]
  108.     private $author;
  109.     #[ORM\OneToMany(targetEntity'App\Entity\Survey\SurveyNotification'mappedBy'survey'cascade: ['persist''remove'], orphanRemovaltrue)]
  110.     public $surveyNotification;
  111.     #[ORM\Column(type'integer')]
  112.     #[Groups(['survey'])]
  113.     private int $refresh;
  114.     #[ORM\Column(type'boolean')]
  115.     private bool $resultMyself;
  116.     #[ORM\Column(type'boolean')]
  117.     private bool $notificationAfterEach;
  118.     #[ORM\Column(type'boolean')]
  119.     private bool $notificationAppointedTime;
  120.     #[ORM\Column(type'datetime'nullabletrue)]
  121.     protected ?\DateTime $notificationDate;
  122.     #[ORM\Column(type'datetime'nullabletrue)]
  123.     protected ?\DateTime $systemDate;
  124.     #[ORM\Column(type'datetime'nullabletrue)]
  125.     protected ?\DateTime $resultFilterStartInNotification;
  126.     #[ORM\Column(type'datetime'nullabletrue)]
  127.     protected ?\DateTime $resultFilterEndInNotification;
  128.     #[ORM\Column(type'boolean')]
  129.     #[Groups(['survey''childrenQuestions'])]
  130.     private bool $timer;
  131.     #[ORM\Column(type'integer'nullabletrue)]
  132.     #[Groups(['survey''childrenQuestions'])]
  133.     protected ?int $timerTime;
  134.     public function __construct()
  135.     {
  136.         $this->surveyQuestion = new ArrayCollection();
  137.         $this->surveyResult = new ArrayCollection();
  138.         $this->surveyNotification = new ArrayCollection();
  139.     }
  140.     public function getUri(): string
  141.     {
  142.         return $this->uri;
  143.     }
  144.     public function setUri(?string $uri): void
  145.     {
  146.         $this->uri $uri;
  147.     }
  148.     public function getTitle(): string
  149.     {
  150.         return $this->title;
  151.     }
  152.     public function setTitle(string $title): void
  153.     {
  154.         $this->title $title;
  155.     }
  156.     public function getDescription(): ?string
  157.     {
  158.         return $this->description;
  159.     }
  160.     public function setDescription(?string $description): void
  161.     {
  162.         $this->description $description;
  163.     }
  164.     public function getStatus(): int
  165.     {
  166.         return $this->status;
  167.     }
  168.     public function setStatus(int $status): void
  169.     {
  170.         $this->status $status;
  171.     }
  172.     public function getValidStart(): ?\DateTime
  173.     {
  174.         return $this->validStart;
  175.     }
  176.     public function setValidStart(?\DateTime $validStart): void
  177.     {
  178.         $this->validStart $validStart;
  179.     }
  180.     public function getValidEnd(): ?\DateTime
  181.     {
  182.         return $this->validEnd;
  183.     }
  184.     public function setValidEnd(?\DateTime $validEnd): void
  185.     {
  186.         $this->validEnd $validEnd;
  187.     }
  188.     /**
  189.      * @return Collection|SurveyQuestion[]
  190.      */
  191.     public function getSurveyQuestion(): Collection
  192.     {
  193.         return $this->surveyQuestion;
  194.     }
  195.     public function addSurveyQuestion(SurveyQuestion $surveyQuestion): void
  196.     {
  197.         $surveyQuestion->setSurvey($this);
  198.         $this->surveyQuestion->add($surveyQuestion);
  199.     }
  200.     public function removeSurveyQuestion(SurveyQuestion $surveyQuestion): void
  201.     {
  202.         if ($this->surveyQuestion->contains($surveyQuestion)) {
  203.             $this->surveyQuestion->removeElement($surveyQuestion);
  204.         }
  205.     }
  206.     /**
  207.      * @return Collection|SurveyResult[]
  208.      */
  209.     public function getSurveyResult(): Collection
  210.     {
  211.         return $this->surveyResult;
  212.     }
  213.     /**
  214.      * @return User
  215.      */
  216.     public function getAuthor(): ?User
  217.     {
  218.         return $this->author;
  219.     }
  220.     /**
  221.      * @param User $author
  222.      */
  223.     public function setAuthor(User $author): void
  224.     {
  225.         $this->author $author;
  226.     }
  227.     /**
  228.      * @return Collection|SurveyNotification[]
  229.      */
  230.     public function getSurveyNotification(): Collection
  231.     {
  232.         return $this->surveyNotification;
  233.     }
  234.     public function addSurveyNotification(SurveyNotification $surveyNotification): void
  235.     {
  236.         $surveyNotification->setSurvey($this);
  237.         $this->surveyNotification->add($surveyNotification);
  238.     }
  239.     public function removeSurveyNotification(SurveyNotification $surveyNotification): void
  240.     {
  241.         if ($this->surveyNotification->contains($surveyNotification)) {
  242.             $this->surveyNotification->removeElement($surveyNotification);
  243.         }
  244.     }
  245.     public function getType(): int
  246.     {
  247.         return $this->type;
  248.     }
  249.     public function setType(int $type): void
  250.     {
  251.         $this->type $type;
  252.     }
  253.     public function getRefresh(): int
  254.     {
  255.         return $this->refresh;
  256.     }
  257.     public function setRefresh(int $refresh): void
  258.     {
  259.         $this->refresh $refresh;
  260.     }
  261.     public function getResultMyself(): bool
  262.     {
  263.         return $this->resultMyself;
  264.     }
  265.     public function setResultMyself(bool $resultMyself): void
  266.     {
  267.         $this->resultMyself $resultMyself;
  268.     }
  269.     public function getNotificationAfterEach(): bool
  270.     {
  271.         return $this->notificationAfterEach;
  272.     }
  273.     public function setNotificationAfterEach(bool $notificationAfterEach): void
  274.     {
  275.         $this->notificationAfterEach $notificationAfterEach;
  276.     }
  277.     public function getNotificationAppointedTime(): bool
  278.     {
  279.         return $this->notificationAppointedTime;
  280.     }
  281.     public function setNotificationAppointedTime(bool $notificationAppointedTime): void
  282.     {
  283.         $this->notificationAppointedTime $notificationAppointedTime;
  284.     }
  285.     public function getNotificationDate(): ?\DateTime
  286.     {
  287.         return $this->notificationDate;
  288.     }
  289.     public function setNotificationDate(?\DateTime $notificationDate): void
  290.     {
  291.         $this->notificationDate $notificationDate;
  292.     }
  293.     public function getSystemDate(): ?\DateTime
  294.     {
  295.         return $this->systemDate;
  296.     }
  297.     public function setSystemDate(?\DateTime $systemDate): void
  298.     {
  299.         $this->systemDate $systemDate;
  300.     }
  301.     public function getResultFilterStartInNotification(): ?\DateTime
  302.     {
  303.         return $this->resultFilterStartInNotification;
  304.     }
  305.     public function setResultFilterStartInNotification(?\DateTime $resultFilterStartInNotification): void
  306.     {
  307.         $this->resultFilterStartInNotification $resultFilterStartInNotification;
  308.     }
  309.     public function getResultFilterEndInNotification(): ?\DateTime
  310.     {
  311.         return $this->resultFilterEndInNotification;
  312.     }
  313.     public function setResultFilterEndInNotification(?\DateTime $resultFilterEndInNotification): void
  314.     {
  315.         $this->resultFilterEndInNotification $resultFilterEndInNotification;
  316.     }
  317.     public function getTimer(): bool
  318.     {
  319.         return $this->timer;
  320.     }
  321.     public function setTimer(bool $timer): void
  322.     {
  323.         $this->timer $timer;
  324.     }
  325.     public function getTimerTime(): ?int
  326.     {
  327.         return $this->timerTime;
  328.     }
  329.     public function setTimerTime(?int $timerTime): void
  330.     {
  331.         $this->timerTime $timerTime;
  332.     }
  333. }