<?php
namespace App\Entity;
use App\Repository\MediaItemRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=MediaItemRepository::class)
* @ORM\Table(name="media_item")
*/
class MediaItem
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Instance::class)
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $instance;
/**
* @ORM\ManyToOne(targetEntity=InstanceView::class)
* @ORM\JoinColumn(nullable=true, onDelete="SET NULL")
*/
private $view;
/**
* @ORM\Column(name="row_pos", type="integer", options={"default" = 1})
*/
private $row = 1;
/**
* @ORM\Column(type="string", length=20)
*/
private $type;
/**
* @ORM\Column(type="string", length=255)
*/
private $originalFilename;
/**
* @ORM\Column(type="string", length=255)
*/
private $originalPath;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $variants = [];
/**
* @ORM\Column(type="string", length=50)
*/
private $status;
/**
* @ORM\Column(type="string", length=50)
*/
private $sourceType;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $sourceConfig = null;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $updatedAt;
public function __construct()
{
$now = new \DateTimeImmutable();
$this->createdAt = $now;
$this->updatedAt = $now;
$this->status = 'pending_download';
$this->variants = [];
}
public function getId(): ?int
{
return $this->id;
}
public function getInstance(): ?Instance
{
return $this->instance;
}
public function setInstance(Instance $instance): self
{
$this->instance = $instance;
return $this;
}
public function getView(): ?InstanceView
{
return $this->view;
}
public function setView(?InstanceView $view): self
{
$this->view = $view;
return $this;
}
public function getRow(): int
{
return $this->row ?? 1;
}
public function setRow(int $row): self
{
if ($row <= 0) {
$row = 1;
}
$this->row = $row;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getOriginalFilename(): ?string
{
return $this->originalFilename;
}
public function setOriginalFilename(string $originalFilename): self
{
$this->originalFilename = $originalFilename;
return $this;
}
public function getOriginalPath(): ?string
{
return $this->originalPath;
}
public function setOriginalPath(string $originalPath): self
{
$this->originalPath = $originalPath;
return $this;
}
public function getVariants(): array
{
return $this->variants ?? [];
}
public function setVariants(array $variants): self
{
$this->variants = $variants;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getSourceType(): ?string
{
return $this->sourceType;
}
public function setSourceType(string $sourceType): self
{
$this->sourceType = $sourceType;
return $this;
}
public function getSourceConfig(): ?array
{
return $this->sourceConfig;
}
public function setSourceConfig(?array $sourceConfig): self
{
$this->sourceConfig = $sourceConfig;
return $this;
}
public function getCreatedAt(): \DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): \DateTimeImmutable
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
}