src/Entity/Olympiad/Online/Direction.php line 24

  1. <?php
  2. namespace App\Entity\Olympiad\Online;
  3. use App\Entity\Common\DateInterval;
  4. use App\Entity\Common\DateTimeInterval;
  5. use App\Entity\Common\TimeInterval;
  6. use App\Entity\Traits\ActiveTrait;
  7. use App\Entity\Traits\TrackerFields;
  8. use App\Entity\Traits\UserCreatedInterface;
  9. use App\Entity\Traits\UserUpdatedInterface;
  10. use App\Entity\Traits\WeightTrait;
  11. use App\Model\Translation\TranslatableTrait;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  16. #[ORM\Table(name'olymp_online_direction')]
  17. #[ORM\Entity(repositoryClass'App\Repository\Olympiad\Online\DirectionRepository')]
  18. #[ORM\HasLifecycleCallbacks]
  19. class Direction implements UserCreatedInterfaceUserUpdatedInterfaceTranslatableInterface
  20. {
  21.     use TrackerFields;
  22.     use WeightTrait;
  23.     use ActiveTrait;
  24.     use TranslatableTrait;
  25.     public const APPLY_BY_TEST_TIME 1;
  26.     public const APPLY_IMPLICIT << 1;
  27.     public const APPLY_RULE_RUSSIAN << 2;
  28.     public const APPLY_RULE_REGION_CFO << 3;
  29.     #[ORM\Id]
  30.     #[ORM\GeneratedValue(strategy'AUTO')]
  31.     #[ORM\Column(type'integer')]
  32.     private int $id;
  33.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\Event'inversedBy'directions')]
  34.     #[ORM\JoinColumn(nullablefalse)]
  35.     private Event $event;
  36.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\Category'inversedBy'directions')]
  37.     #[ORM\JoinColumn(nullablefalse)]
  38.     private Category $category;
  39.     /**
  40.      * @var DateTimeInterval
  41.      */
  42.     #[ORM\Embedded(class: 'App\Entity\Common\DateTimeInterval'columnPrefix'tt_')]
  43.     private DateTimeInterval $test_time;
  44.     /**
  45.      * @var DateTimeInterval
  46.      */
  47.     #[ORM\Embedded(class: 'App\Entity\Common\DateTimeInterval'columnPrefix't_ws_')]
  48.     private DateTimeInterval $work_show;
  49.     /**
  50.      * @var DateTimeInterval
  51.      */
  52.     #[ORM\Embedded(class: 'App\Entity\Common\DateTimeInterval'columnPrefix't_as_')]
  53.     private DateTimeInterval $appeal_show;
  54.     /**
  55.      * @var ArrayCollection|Collection|DirectionLanguage[]
  56.      */
  57.     #[ORM\OneToMany(targetEntity'App\Entity\Olympiad\Online\DirectionLanguage'cascade: ['remove''persist'], mappedBy'direction')]
  58.     private Collection $languages;
  59.     #[ORM\Column(type'string'nullabletrue)]
  60.     private string $caption;
  61.     #[ORM\Column(type'string'nullabletrue)]
  62.     private ?string $description null;
  63.     /**
  64.      * @var string|null
  65.      */
  66.     #[ORM\Column(type'text'nullabletrue)]
  67.     private ?string $formJs null;
  68.     /**
  69.      * @var Collection
  70.      */
  71.     #[ORM\OneToMany(targetEntity'App\Entity\Olympiad\Online\Participant'mappedBy'direction')]
  72.     private Collection $participants;
  73.     /**
  74.      * @var array|null
  75.      */
  76.     #[ORM\Column(type'json')]
  77.     private ?array $moodle_courses = [];
  78.     #[ORM\Column(type'integer'nullabletrue,)]
  79.     private ?int $moodle_course null;
  80.     #[ORM\Column(type'integer'nullabletrue,)]
  81.     private ?int $moodle_element null;
  82.     /**
  83.      * @var int
  84.      */
  85.     #[ORM\Column(type'integer'nullablefalseoptions: ['default' => 1])]
  86.     private int $applyAllow self::APPLY_BY_TEST_TIME;
  87.     public function __construct()
  88.     {
  89.         $this->languages = new ArrayCollection();
  90. //        $this->fields = new ArrayCollection();
  91.         $this->participants = new ArrayCollection();
  92. //        $this->interval = new DateInterval();
  93. //        $this->registration_open = new DateTimeInterval();
  94.         $this->test_time = new DateTimeInterval();
  95.         $this->work_show = new DateTimeInterval();
  96.         $this->appeal_show = new DateTimeInterval();
  97. //        $this->timeInterval = new TimeInterval();
  98.     }
  99.     /**
  100.      * @return int
  101.      */
  102.     public function getId(): int
  103.     {
  104.         return $this->id;
  105.     }
  106.     /**
  107.      * @param int $id
  108.      */
  109.     public function setId(int $id): void
  110.     {
  111.         $this->id $id;
  112.     }
  113.     /**
  114.      * @return Event
  115.      */
  116.     public function getEvent(): Event
  117.     {
  118.         return $this->event;
  119.     }
  120.     /**
  121.      * @param Event $event
  122.      */
  123.     public function setEvent(Event $event): void
  124.     {
  125.         $this->event $event;
  126.     }
  127.     /**
  128.      * @return string|null
  129.      */
  130.     public function getDescription(): ?string
  131.     {
  132.         return $this->description;
  133.     }
  134.     /**
  135.      * @param string|null $description
  136.      */
  137.     public function setDescription(?string $description): void
  138.     {
  139.         $this->description $description;
  140.     }
  141.     /**
  142.      * @return string|null
  143.      */
  144.     public function getFormJs(): ?string
  145.     {
  146.         return $this->formJs;
  147.     }
  148.     /**
  149.      * @param string|null $formJs
  150.      */
  151.     public function setFormJs(?string $formJs): void
  152.     {
  153.         $this->formJs $formJs;
  154.     }
  155.     /**
  156.      * @return Collection
  157.      */
  158.     public function getParticipants()
  159.     {
  160.         return $this->participants;
  161.     }
  162.     /**
  163.      * @param Collection $participants
  164.      */
  165.     public function setParticipants($participants): void
  166.     {
  167.         $this->participants $participants;
  168.     }
  169.     /**
  170.      * @return DateInterval
  171.      */
  172. //    public function getInterval(): DateInterval
  173. //    {
  174. //        return $this->interval;
  175. //    }
  176.     /**
  177.      * @param DateInterval $interval
  178.      */
  179. //    public function setInterval(DateInterval $interval): void
  180. //    {
  181. //        $this->interval = $interval;
  182. //    }
  183.     /**
  184.      * @return array
  185.      */
  186.     public function getMoodleCourses(): array
  187.     {
  188.         if (is_null($this->moodle_courses)) {
  189.             return [];
  190.         }
  191.         return $this->moodle_courses;
  192.     }
  193.     /**
  194.      * @param array|null $moodle_courses
  195.      */
  196.     public function setMoodleCourses(?array $moodle_courses): void
  197.     {
  198.         $this->moodle_courses $moodle_courses;
  199.     }
  200.     /**
  201.      * @return DateTimeInterval
  202.      */
  203.     public function getTestTime(): DateTimeInterval
  204.     {
  205.         return $this->test_time;
  206.     }
  207.     /**
  208.      * @param DateTimeInterval $test_time
  209.      */
  210.     public function setTestTime(DateTimeInterval $test_time): void
  211.     {
  212.         $this->test_time $test_time;
  213.     }
  214.     /**
  215.      * @return TimeInterval
  216.      */
  217. //    public function getTimeInterval(): TimeInterval
  218. //    {
  219. //        return $this->timeInterval;
  220. //    }
  221.     /**
  222.      * @param TimeInterval $timeInterval
  223.      */
  224. //    public function setTimeInterval(TimeInterval $timeInterval): void
  225. //    {
  226. //        $this->timeInterval = $timeInterval;
  227. //    }
  228.     /**
  229.      * @return DateTimeInterval
  230.      */
  231. //    public function getRegistrationOpen(): DateTimeInterval
  232. //    {
  233. //        return $this->registration_open;
  234. //    }
  235.     /**
  236.      * @param DateTimeInterval $registration_open
  237.      */
  238. //    public function setRegistrationOpen(DateTimeInterval $registration_open): void
  239. //    {
  240. //        $this->registration_open = $registration_open;
  241. //    }
  242.     /**
  243.      * @return Category
  244.      */
  245.     public function getCategory(): Category
  246.     {
  247.         return $this->category;
  248.     }
  249.     /**
  250.      * @param Category $category
  251.      */
  252.     public function setCategory(Category $category): void
  253.     {
  254.         $this->category $category;
  255.     }
  256.     /**
  257.      * @return int
  258.      */
  259.     public function getApplyAllow(): int
  260.     {
  261.         return $this->applyAllow;
  262.     }
  263.     /**
  264.      * @param int $applyAllow
  265.      */
  266.     public function setApplyAllow(int $applyAllow): void
  267.     {
  268.         $this->applyAllow $applyAllow;
  269.     }
  270.     /**
  271.      * @return DateTimeInterval
  272.      */
  273.     public function getWorkShow(): DateTimeInterval
  274.     {
  275.         return $this->work_show;
  276.     }
  277.     /**
  278.      * @param DateTimeInterval $work_show
  279.      */
  280.     public function setWorkShow(DateTimeInterval $work_show): void
  281.     {
  282.         $this->work_show $work_show;
  283.     }
  284.     /**
  285.      * @return DateTimeInterval
  286.      */
  287.     public function getAppealShow(): DateTimeInterval
  288.     {
  289.         return $this->appeal_show;
  290.     }
  291.     /**
  292.      * @param DateTimeInterval $appeal_show
  293.      */
  294.     public function setAppealShow(DateTimeInterval $appeal_show): void
  295.     {
  296.         $this->appeal_show $appeal_show;
  297.     }
  298.     /**
  299.      * @return ArrayCollection|Collection|DirectionLanguage[]
  300.      */
  301.     public function getLanguages()
  302.     {
  303.         return $this->languages;
  304.     }
  305.     /**
  306.      * @param ArrayCollection|Collection $languages
  307.      */
  308.     public function setLanguages($languages): void
  309.     {
  310.         $this->languages $languages;
  311.     }
  312.     public function getCaption(){
  313.         return $this->translate()->getCaption();
  314.     }
  315.     public function getMoodleCourse(): ?int
  316.     {
  317.         return $this->moodle_course;
  318.     }
  319.     public function setMoodleCourse(?int $moodle_course): void
  320.     {
  321.         $this->moodle_course $moodle_course;
  322.     }
  323.     public function getMoodleElement(): ?int
  324.     {
  325.         return $this->moodle_element;
  326.     }
  327.     public function setMoodleElement(?int $moodle_element): void
  328.     {
  329.         $this->moodle_element $moodle_element;
  330.     }
  331. }