<?php
declare(strict_types=1);
namespace App\Entity\Core;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Core\Quiz\Quiz;
use App\Services\Admin\MediaEntityHelper;
#[ORM\Table('audio_reference')]
#[ORM\Entity]
class AudioReference implements MediaInterface
{
public const UPLOAD_DIRECTORY = 'uploads/audio/';
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
/**
* @var string
*
* SHA1 hash of the file
*/
#[ORM\Column(name: 'content_hash', type: 'string', length: 255, nullable: true)]
private ?string $contentHash;
/**
* @var string
*
* Name for referencing the specific audio within a publication
*/
#[ORM\Column(name: 'reference_name', type: 'string', length: 100, nullable: false)]
private string $referenceName;
/**
* @var string
*/
#[ORM\Column(name: 'file_path', type: 'string', length: 255, nullable: true)]
private ?string $filePath;
/**
* @var string
*/
#[ORM\Column(name: 'credit_text', type: 'string', length: 255, nullable: true)]
private ?string $creditText;
/**
* @var string
*/
#[ORM\Column(name: 'position', type: 'string', length: 255, nullable: true)]
private ?string $position;
/**
* @var ?string
*/
#[ORM\Column(name: 'alt_text', type: 'string', length: 255, nullable: true)]
private ?string $altText;
#[ORM\JoinColumn(name: 'publication', referencedColumnName: 'id', nullable: true)]
#[ORM\ManyToOne(targetEntity: Publication::class)]
private ?Publication $publication;
#[ORM\OneToOne(targetEntity: Mathproblem::class, mappedBy: 'audioReference')]
private ?Mathproblem $mathproblem;
#[ORM\OneToOne(targetEntity: Quiz::class, mappedBy: 'audioReference')]
private ?Quiz $quiz;
#[ORM\OneToOne(targetEntity: Answer::class, mappedBy: 'audioReference')]
private ?Answer $answer;
#[ORM\OneToOne(targetEntity: ProblemDndBin::class, mappedBy: 'audioReference')]
private ?ProblemDndBin $problemDndBin;
/**
* @var ?bool
*/
#[ORM\Column(name: 'is_deleted', type: 'boolean', nullable: true)]
private ?bool $isDeleted = false;
public function __construct()
{
$this->mathproblem = null;
$this->contentHash = null;
$this->filePath = null;
}
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): void
{
$this->id = $id;
}
public function getContentHash(): ?string
{
return $this->contentHash;
}
public function setContentHash(?string $contentHash): void
{
$this->contentHash = $contentHash;
}
public function getFilePath(): ?string
{
return $this->filePath;
}
public function setFilePath(?string $filePath): void
{
$this->filePath = $filePath;
}
public function getCreditText(): ?string
{
return $this->creditText;
}
public function setCreditText(?string $creditText): void
{
$this->creditText = $creditText;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(?string $position): void
{
$this->position = $position;
}
public function getAltText(): ?string
{
return $this->altText;
}
public function setAltText(?string $altText): void
{
$this->altText = $altText;
}
public function getPublication(): ?Publication
{
return $this->publication;
}
public function setPublication(?Publication $publication): void
{
$this->publication = $publication;
}
public function getReferenceName(): string
{
return $this->referenceName;
}
public function setReferenceName(string $referenceName): void
{
$this->referenceName = $referenceName;
}
public function getMathproblem(): ?Mathproblem
{
return $this->mathproblem;
}
public function setMathproblem(?Mathproblem $mathproblem): void
{
$this->mathproblem = $mathproblem;
}
public function getQuiz(): ?Quiz
{
return $this->quiz;
}
public function setQuiz(Quiz $quiz): void
{
$this->quiz = $quiz;
}
public function getAnswer(): ?Answer
{
return $this->answer;
}
public function setAnswer(?Answer $answer): void
{
$this->answer = $answer;
}
public function getProblemDndBin(): ?ProblemDndBin
{
return $this->problemDndBin;
}
public function setProblemDndBin(?ProblemDndBin $problemDndBin): void
{
$this->problemDndBin = $problemDndBin;
}
// used as field in CMS
public function getUsage()
{
return MediaEntityHelper::getMediaUsages($this);
}
// used as field in CMS
public function isValid(): bool
{
return MediaEntityHelper::isMediaValid($this);
}
public function isUsed(): bool
{
return MediaEntityHelper::isUsed($this);
}
public function numberOfUsages(): int {
return MediaEntityHelper::numberOfUsages($this);
}
public function getIsDeleted(): ?bool
{
return $this->isDeleted;
}
public function setIsDeleted(?bool $isDeleted): void
{
$this->isDeleted = $isDeleted;
}
public function getFullMediaPath(): ?string
{
return $this->filePath ? '/' . self::UPLOAD_DIRECTORY . $this->filePath : null;
}
}