src/Entity/Olympiad/Online/Participant/File.php line 14

  1. <?php
  2. namespace App\Entity\Olympiad\Online\Participant;
  3. use App\Entity\Common\File as UploadedFile;
  4. use App\Entity\Olympiad\Online\Participant;
  5. use App\Entity\Traits\CreatedTrait;
  6. use App\Entity\Traits\UpdatedTrait;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Table(name'olymp_online_participant_file')]
  9. #[ORM\Entity(repositoryClass'App\Repository\Olympiad\Online\Participant\FileRepository')]
  10. #[ORM\HasLifecycleCallbacks]
  11. class File
  12. {
  13.     use CreatedTrait;
  14.     use UpdatedTrait;
  15.     public const   TYPE_WORK_SCAN 'work_scan';
  16.     public const   TYPE_PROTOCOL 'protocol';
  17.     public const TYPE_APPEAL 'appeal';
  18.     public const TYPE_APPEAL_NOTIFY 'appeal_notify';
  19.     public const TYPE_PASSPORT 'passport';
  20.     /**
  21.      * @var int
  22.      */
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue(strategy'AUTO')]
  25.     #[ORM\Column(type'integer')]
  26.     private int $id;
  27.     #[ORM\ManyToOne(targetEntity'App\Entity\Olympiad\Online\Participant')]
  28.     private Participant $participant;
  29.     #[ORM\Column(type'string')]
  30.     private string $type;
  31.     /**
  32.      * @var UploadedFile
  33.      */
  34.     #[ORM\ManyToOne(targetEntity'App\Entity\Common\File')]
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     private UploadedFile $file;
  37.     public static function getParticipantTypes(): array
  38.     {
  39.         return [self::TYPE_WORK_SCANself::TYPE_APPEALself::TYPE_APPEAL_NOTIFYself::TYPE_PROTOCOL];
  40.     }
  41.     /**
  42.      * @return int
  43.      */
  44.     public function getId(): int
  45.     {
  46.         return $this->id;
  47.     }
  48.     /**
  49.      * @param int $id
  50.      */
  51.     public function setId(int $id): void
  52.     {
  53.         $this->id $id;
  54.     }
  55.     /**
  56.      * @return Participant
  57.      */
  58.     public function getParticipant(): Participant
  59.     {
  60.         return $this->participant;
  61.     }
  62.     /**
  63.      * @param Participant $participant
  64.      */
  65.     public function setParticipant(Participant $participant): void
  66.     {
  67.         $this->participant $participant;
  68.     }
  69.     /**
  70.      * @return string
  71.      */
  72.     public function getType(): string
  73.     {
  74.         return $this->type;
  75.     }
  76.     /**
  77.      * @param string $type
  78.      */
  79.     public function setType(string $type): void
  80.     {
  81.         $this->type $type;
  82.     }
  83.     /**
  84.      * @return UploadedFile
  85.      */
  86.     public function getFile(): UploadedFile
  87.     {
  88.         return $this->file;
  89.     }
  90.     /**
  91.      * @param UploadedFile $file
  92.      */
  93.     public function setFile(UploadedFile $file): void
  94.     {
  95.         $this->file $file;
  96.         $this->file->setPublic(false);
  97.     }
  98. }