src/Entity/LocationDetail.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocationDetailRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=LocationDetailRepository::class)
  7.  * @ORM\Table(name="location_detail")
  8.  * @ORM\HasLifecycleCallbacks()
  9.  */
  10. class LocationDetail
  11. {
  12.     public const TYPE_TEXT  'text';
  13.     public const TYPE_AUDIO 'audio';
  14.     public const TYPE_VIDEO 'video';
  15.     public const TYPES = [
  16.         self::TYPE_TEXT,
  17.         self::TYPE_AUDIO,
  18.         self::TYPE_VIDEO,
  19.     ];
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private ?int $id null;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Location::class, inversedBy="details")
  28.      * @ORM\JoinColumn(nullable=false)
  29.      */
  30.     private Location $location;
  31.     /**
  32.      * "text", "audio" or "video"
  33.      * @ORM\Column(type="string", length=10)
  34.      */
  35.     private string $type;
  36.     /**
  37.      * @ORM\Column(type="string", length=200)
  38.      */
  39.     private string $title;
  40.     /**
  41.      * Stores the body for type=text, or a transcript for audio/video
  42.      * @ORM\Column(type="text", nullable=true)
  43.      */
  44.     private ?string $content null;
  45.     /**
  46.      * Relative storage path for audio/video files (e.g. S3 key or local path)
  47.      * @ORM\Column(type="string", length=500, nullable=true)
  48.      */
  49.     private ?string $filePath null;
  50.     /**
  51.      * ISO 639-1 language code, e.g. "en", "hy", "fr"
  52.      * @ORM\Column(type="string", length=5, nullable=true)
  53.      */
  54.     private ?string $language null;
  55.     /**
  56.      * Display order among siblings on the same location
  57.      * @ORM\Column(type="integer", options={"default": 0})
  58.      */
  59.     private int $sortOrder 0;
  60.     /**
  61.      * @ORM\Column(type="boolean", options={"default": true})
  62.      */
  63.     private bool $isActive true;
  64.     /**
  65.      * @ORM\Column(type="datetime_immutable")
  66.      */
  67.     private \DateTimeImmutable $createdAt;
  68.     /**
  69.      * @ORM\Column(type="datetime_immutable", nullable=true)
  70.      */
  71.     private ?\DateTimeImmutable $updatedAt null;
  72.     public function __construct()
  73.     {
  74.         $this->createdAt = new \DateTimeImmutable();
  75.     }
  76.     /**
  77.      * @ORM\PreUpdate()
  78.      */
  79.     public function onPreUpdate(): void
  80.     {
  81.         $this->updatedAt = new \DateTimeImmutable();
  82.     }
  83.     public function getId(): ?int
  84.     {
  85.         return $this->id;
  86.     }
  87.     public function getLocation(): Location
  88.     {
  89.         return $this->location;
  90.     }
  91.     public function setLocation(?Location $location): self
  92.     {
  93.         $this->location $location;
  94.         return $this;
  95.     }
  96.     public function getType(): string
  97.     {
  98.         return $this->type;
  99.     }
  100.     public function setType(string $type): self
  101.     {
  102.         if (!in_array($typeself::TYPEStrue)) {
  103.             throw new \InvalidArgumentException(sprintf(
  104.                 'Invalid type "%s". Allowed: %s',
  105.                 $type,
  106.                 implode(', 'self::TYPES)
  107.             ));
  108.         }
  109.         $this->type $type;
  110.         return $this;
  111.     }
  112.     public function getTitle(): string
  113.     {
  114.         return $this->title;
  115.     }
  116.     public function setTitle(string $title): self
  117.     {
  118.         $this->title $title;
  119.         return $this;
  120.     }
  121.     public function getContent(): ?string
  122.     {
  123.         return $this->content;
  124.     }
  125.     public function setContent(?string $content): self
  126.     {
  127.         $this->content $content;
  128.         return $this;
  129.     }
  130.     public function getFilePath(): ?string
  131.     {
  132.         return $this->filePath;
  133.     }
  134.     public function setFilePath(?string $filePath): self
  135.     {
  136.         $this->filePath $filePath;
  137.         return $this;
  138.     }
  139.     public function getLanguage(): ?string
  140.     {
  141.         return $this->language;
  142.     }
  143.     public function setLanguage(?string $language): self
  144.     {
  145.         $this->language $language;
  146.         return $this;
  147.     }
  148.     public function getSortOrder(): int
  149.     {
  150.         return $this->sortOrder;
  151.     }
  152.     public function setSortOrder(int $sortOrder): self
  153.     {
  154.         $this->sortOrder $sortOrder;
  155.         return $this;
  156.     }
  157.     public function isActive(): bool
  158.     {
  159.         return $this->isActive;
  160.     }
  161.     public function setIsActive(bool $isActive): self
  162.     {
  163.         $this->isActive $isActive;
  164.         return $this;
  165.     }
  166.     public function getCreatedAt(): \DateTimeImmutable
  167.     {
  168.         return $this->createdAt;
  169.     }
  170.     public function getUpdatedAt(): ?\DateTimeImmutable
  171.     {
  172.         return $this->updatedAt;
  173.     }
  174. }