<?php
declare(strict_types=1);
namespace CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AdminBundle\Service\MediaEntityHelper;
/**
* @ORM\Table("image_reference")
* @ORM\Entity()
*/
class ImageReference implements MediaInterface
{
public const UPLOAD_DIRECTORY = 'uploads/images/';
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var ?string
*
* SHA1 hash of the image
*
* @ORM\Column(name="content_hash", type="string", length=255, nullable=true)
*/
private ?string $contentHash;
/**
* @var string
*
* Name for referencing the specific image 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\ManyToOne(targetEntity="CoreBundle\Entity\Publication")
* @ORM\JoinColumn(name="publication", referencedColumnName="id", nullable=true)
*/
private ?Publication $publication;
/**
* @ORM\OneToOne(targetEntity="CoreBundle\Entity\Mathproblem", mappedBy="imageReference")
*/
private ?Mathproblem $mathproblem;
/**
* @ORM\OneToOne(targetEntity="CoreBundle\Entity\Quiz", mappedBy="imageReference")
*/
private ?Quiz $quiz;
/**
* @ORM\OneToOne(targetEntity="CoreBundle\Entity\Answer", mappedBy="imageReference")
*/
private ?Answer $answer;
/**
* @ORM\OneToOne(targetEntity="CoreBundle\Entity\ProblemDndBin", mappedBy="imageReference")
*/
private ?ProblemDndBin $problemDndBin;
/**
* @var ?bool
*
* @ORM\Column(name="is_deleted", type="boolean", nullable=true)
*/
private ?bool $isDeleted = false;
/**
* @var ?int
*
* Width of the image in pixels
*
* @ORM\Column(name="image_pixel_width", type="integer", nullable=true)
*/
private ?int $imagePixelWidth = null;
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;
}
public function getImagePixelWidth(): ?int
{
return $this->imagePixelWidth;
}
public function setImagePixelWidth(?int $imagePixelWidth): void
{
$this->imagePixelWidth = $imagePixelWidth;
}
}