src/CoreBundle/Entity/AudioReference.php line 13

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace CoreBundle\Entity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use AdminBundle\Service\MediaEntityHelper;
  6. /**
  7. * @ORM\Table("audio_reference")
  8. * @ORM\Entity()
  9. */
  10. class AudioReference implements MediaInterface
  11. {
  12. public const UPLOAD_DIRECTORY = 'uploads/audio/';
  13. /**
  14. * @ORM\Column(name="id", type="integer")
  15. * @ORM\Id
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. */
  18. private $id;
  19. /**
  20. * @var string
  21. *
  22. * SHA1 hash of the file
  23. *
  24. * @ORM\Column(name="content_hash", type="string", length=255, nullable=true)
  25. */
  26. private ?string $contentHash;
  27. /**
  28. * @var string
  29. *
  30. * Name for referencing the specific audio within a publication
  31. *
  32. * @ORM\Column(name="reference_name", type="string", length=100, nullable=false)
  33. */
  34. private string $referenceName;
  35. /**
  36. * @var string
  37. *
  38. * @ORM\Column(name="file_path", type="string", length=255, nullable=true)
  39. */
  40. private ?string $filePath;
  41. /**
  42. * @var string
  43. *
  44. * @ORM\Column(name="credit_text", type="string", length=255, nullable=true)
  45. */
  46. private ?string $creditText;
  47. /**
  48. * @var string
  49. *
  50. * @ORM\Column(name="position", type="string", length=255, nullable=true)
  51. */
  52. private ?string $position;
  53. /**
  54. * @var ?string
  55. *
  56. * @ORM\Column(name="alt_text", type="string", length=255, nullable=true)
  57. */
  58. private ?string $altText;
  59. /**
  60. * @ORM\ManyToOne(targetEntity="CoreBundle\Entity\Publication")
  61. * @ORM\JoinColumn(name="publication", referencedColumnName="id", nullable=true)
  62. */
  63. private ?Publication $publication;
  64. /**
  65. * @ORM\OneToOne(targetEntity="CoreBundle\Entity\Mathproblem", mappedBy="audioReference")
  66. */
  67. private ?Mathproblem $mathproblem;
  68. /**
  69. * @ORM\OneToOne(targetEntity="CoreBundle\Entity\Quiz", mappedBy="audioReference")
  70. */
  71. private ?Quiz $quiz;
  72. /**
  73. * @ORM\OneToOne(targetEntity="CoreBundle\Entity\Answer", mappedBy="audioReference")
  74. */
  75. private ?Answer $answer;
  76. /**
  77. * @ORM\OneToOne(targetEntity="CoreBundle\Entity\ProblemDndBin", mappedBy="audioReference")
  78. */
  79. private ?ProblemDndBin $problemDndBin;
  80. /**
  81. * @var ?bool
  82. *
  83. * @ORM\Column(name="is_deleted", type="boolean", nullable=true)
  84. */
  85. private ?bool $isDeleted = false;
  86. public function __construct()
  87. {
  88. $this->mathproblem = null;
  89. $this->contentHash = null;
  90. $this->filePath = null;
  91. }
  92. public function getId(): ?int
  93. {
  94. return $this->id;
  95. }
  96. public function setId(int $id): void
  97. {
  98. $this->id = $id;
  99. }
  100. public function getContentHash(): ?string
  101. {
  102. return $this->contentHash;
  103. }
  104. public function setContentHash(?string $contentHash): void
  105. {
  106. $this->contentHash = $contentHash;
  107. }
  108. public function getFilePath(): ?string
  109. {
  110. return $this->filePath;
  111. }
  112. public function setFilePath(?string $filePath): void
  113. {
  114. $this->filePath = $filePath;
  115. }
  116. public function getCreditText(): ?string
  117. {
  118. return $this->creditText;
  119. }
  120. public function setCreditText(?string $creditText): void
  121. {
  122. $this->creditText = $creditText;
  123. }
  124. public function getPosition(): ?string
  125. {
  126. return $this->position;
  127. }
  128. public function setPosition(?string $position): void
  129. {
  130. $this->position = $position;
  131. }
  132. public function getAltText(): ?string
  133. {
  134. return $this->altText;
  135. }
  136. public function setAltText(?string $altText): void
  137. {
  138. $this->altText = $altText;
  139. }
  140. public function getPublication(): ?Publication
  141. {
  142. return $this->publication;
  143. }
  144. public function setPublication(?Publication $publication): void
  145. {
  146. $this->publication = $publication;
  147. }
  148. public function getReferenceName(): string
  149. {
  150. return $this->referenceName;
  151. }
  152. public function setReferenceName(string $referenceName): void
  153. {
  154. $this->referenceName = $referenceName;
  155. }
  156. public function getMathproblem(): ?Mathproblem
  157. {
  158. return $this->mathproblem;
  159. }
  160. public function setMathproblem(?Mathproblem $mathproblem): void
  161. {
  162. $this->mathproblem = $mathproblem;
  163. }
  164. public function getQuiz(): ?Quiz
  165. {
  166. return $this->quiz;
  167. }
  168. public function setQuiz(Quiz $quiz): void
  169. {
  170. $this->quiz = $quiz;
  171. }
  172. public function getAnswer(): ?Answer
  173. {
  174. return $this->answer;
  175. }
  176. public function setAnswer(?Answer $answer): void
  177. {
  178. $this->answer = $answer;
  179. }
  180. public function getProblemDndBin(): ?ProblemDndBin
  181. {
  182. return $this->problemDndBin;
  183. }
  184. public function setProblemDndBin(?ProblemDndBin $problemDndBin): void
  185. {
  186. $this->problemDndBin = $problemDndBin;
  187. }
  188. // used as field in CMS
  189. public function getUsage()
  190. {
  191. return MediaEntityHelper::getMediaUsages($this);
  192. }
  193. // used as field in CMS
  194. public function isValid(): bool
  195. {
  196. return MediaEntityHelper::isMediaValid($this);
  197. }
  198. public function isUsed(): bool
  199. {
  200. return MediaEntityHelper::isUsed($this);
  201. }
  202. public function numberOfUsages(): int {
  203. return MediaEntityHelper::numberOfUsages($this);
  204. }
  205. public function getIsDeleted(): ?bool
  206. {
  207. return $this->isDeleted;
  208. }
  209. public function setIsDeleted(?bool $isDeleted): void
  210. {
  211. $this->isDeleted = $isDeleted;
  212. }
  213. public function getFullMediaPath(): ?string
  214. {
  215. return $this->filePath ? '/' . self::UPLOAD_DIRECTORY . $this->filePath : null;
  216. }
  217. }