src/Entity/Hymns.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Exception;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10. * Hymns
  11. *
  12. * @ORM\Table(name="hymns")
  13. * @ORM\Entity(repositoryClass="App\Repository\HymnsRepository")
  14. */
  15. class Hymns
  16. {
  17. /**
  18. * @var int
  19. *
  20. * @ORM\Column(type="integer", name="id", options={"unsigned":true})
  21. * @ORM\Id
  22. * @ORM\GeneratedValue(strategy="IDENTITY")
  23. */
  24. private int $id = 0;
  25. /**
  26. * @var string
  27. *
  28. * @ORM\Column(type="string", length=255, nullable=false, name="title")
  29. */
  30. private string $title = '';
  31. /**
  32. * @Gedmo\Slug(fields={"title","slug"})
  33. * @ORM\Column(type="string", unique=true, length=255, nullable=false)
  34. */
  35. private string $slug = '';
  36. /**
  37. * @var int
  38. *
  39. * @ORM\Column(type="integer", nullable=false, name="author_id")
  40. */
  41. private int $author_id = 713;
  42. /**
  43. * @var int|null
  44. *
  45. * @ORM\Column(type="integer", nullable=true, name="LyricYYYY")
  46. */
  47. private ?int $lyricyyyy;
  48. /**
  49. * @var int
  50. *
  51. * @ORM\Column(type="integer", nullable=false, name="composer_id")
  52. */
  53. private int $composer_id = 713;
  54. /**
  55. * @var int|null
  56. *
  57. * @ORM\Column(type="integer", nullable=true, name="MusicYYYY")
  58. */
  59. private ?int $musicyyyy;
  60. /**
  61. * @var int
  62. *
  63. * @ORM\Column(type="integer", nullable=false, name="arranger_id")
  64. */
  65. private int $arranger_id = 713;
  66. /**
  67. * @var int|null
  68. *
  69. * @ORM\Column(type="integer", nullable=true, name="ArrangedYYYY")
  70. */
  71. private ?int $arrangedyyyy;
  72. /**
  73. * @var int
  74. *
  75. * @ORM\Column(type="integer", nullable=false, name="type_id")
  76. * @ORM\JoinColumn(nullable=false, referencedColumnName="id")
  77. */
  78. private int $type_id = 1;
  79. /**
  80. * @var string|null
  81. *
  82. * @ORM\Column(type="text", length=65535, nullable=true, name="OtherNotes")
  83. */
  84. private ?string $othernotes;
  85. /**
  86. * @var string|null
  87. *
  88. * @ORM\Column(type="text", length=65535, nullable=true, name="text")
  89. */
  90. private ?string $text;
  91. /**
  92. * @var string|null
  93. *
  94. * @ORM\Column(type="string", length=200, nullable=true, name="copyright")
  95. */
  96. private ?string $copyright;
  97. /**
  98. * @ORM\Column(type="integer", nullable=false, name="score_page_count")
  99. */
  100. private int $score_page_count = 1;
  101. /**
  102. * @var int
  103. *
  104. * @ORM\Column(type="integer", nullable=false, name="hymn_hit_count")
  105. */
  106. private int $hymn_hit_count = 0;
  107. /**
  108. * @var DateTime
  109. *
  110. * @ORM\Column(type="datetime", nullable=false, name="last_accessed", options={"default":"CURRENT_TIMESTAMP"})
  111. */
  112. private DateTime $last_accessed;
  113. /**
  114. * @var DateTime|null
  115. *
  116. * @ORM\Column(type="datetime", nullable=true, name="created_at")
  117. */
  118. private ?DateTime $created_at;
  119. /**
  120. * @var DateTime|null
  121. *
  122. * @ORM\Column(type="datetime", nullable=true, name="updated_at")
  123. */
  124. private ?DateTime $updated_at;
  125. /**
  126. * @var string
  127. */
  128. private string $FirstLetter;
  129. /**
  130. * @var string
  131. */
  132. private string $nextFL;
  133. /**
  134. * @var string
  135. */
  136. private string $prevSlug;
  137. /**
  138. * @var string
  139. */
  140. private string $nextSlug;
  141. /**
  142. * @var Hymntypes|null
  143. *
  144. * @ORM\ManyToOne(targetEntity="App\Entity\Hymntypes", inversedBy="hymns")
  145. * @ORM\JoinColumn(nullable=false, referencedColumnName="id")
  146. */
  147. private ?Hymntypes $type;
  148. /**
  149. * @var Collection|null
  150. *
  151. * @ORM\ManyToMany(targetEntity="App\Entity\HymnCategory", inversedBy="hymns")
  152. * @ORM\JoinColumn(nullable=true, referencedColumnName="id")
  153. */
  154. private ?Collection $category;
  155. /**
  156. * @var Authcomp|null
  157. *
  158. * @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="auth_hymns")
  159. * @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
  160. */
  161. private ?Authcomp $author;
  162. /**
  163. * @var Authcomp|null
  164. *
  165. * @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="comp_hymns")
  166. * @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
  167. */
  168. private ?Authcomp $composer;
  169. /**
  170. * @var Authcomp|null
  171. *
  172. * @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="arr_hymns")
  173. * @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
  174. */
  175. private ?Authcomp $arranger;
  176. /**
  177. * @Assert\File(
  178. * maxSize = "1024k",
  179. * mimeTypes = {"application/pdf", "application/x-pdf"},
  180. * mimeTypesMessage = "Please upload a valid PDF"
  181. * )
  182. * @var string|null
  183. */
  184. private ?string $pdfFileName;
  185. /**
  186. * @Assert\File(
  187. * maxSize = "1024k",
  188. * mimeTypes = {"application/jpg", "application/jpeg"},
  189. * mimeTypesMessage = "Please upload a valid Hymn image"
  190. * )
  191. * @var string|null
  192. */
  193. private ?string $imgFileName;
  194. /**
  195. * @Assert\File(
  196. * maxSize = "1024k",
  197. * mimeTypes = {"application/midi", "application/wav", "application/mp3"},
  198. * mimeTypesMessage = "Please upload a valid audio file"
  199. * )
  200. * @var string|null
  201. */
  202. private ?string $midiFileName;
  203. /**
  204. * @Assert\File(
  205. * maxSize = "1024k",
  206. * mimeTypes = {"audio/mpeg"},
  207. * mimeTypesMessage = "Please upload a valid audio file"
  208. * )
  209. * @var string|null
  210. */
  211. private ?string $mp3FileName;
  212. /**
  213. * @Assert\File(
  214. * maxSize = "1024k",
  215. * mimeTypes = {"application/xml"},
  216. * mimeTypesMessage = "Please upload a valid Music XML file"
  217. * )
  218. * @var string|null
  219. */
  220. private ?string $xmlFileName;
  221. /**
  222. * Hymns constructor.
  223. * @throws Exception
  224. */
  225. public function __construct()
  226. {
  227. $this->setLastAccessed(new DateTime('now'));
  228. $this->copyright = 'Arr. Copyright © ' . date('Y') . ' Manz Music Publishing';
  229. }
  230. /**
  231. * @return int|null
  232. */
  233. public function getId(): ?int
  234. {
  235. return $this->id;
  236. }
  237. /**
  238. * @return string|null
  239. */
  240. public function getTitle(): ?string
  241. {
  242. return $this->title;
  243. }
  244. /**
  245. * @param string $title
  246. *
  247. * @return $this
  248. */
  249. public function setTitle(string $title): self
  250. {
  251. $this->title = $title;
  252. return $this;
  253. }
  254. /**
  255. * @return string|null
  256. */
  257. public function getSlug(): ?string
  258. {
  259. return $this->slug;
  260. }
  261. /**
  262. * @param string $slug
  263. *
  264. * @return $this
  265. */
  266. public function setSlug(string $slug): self
  267. {
  268. $this->slug = $slug;
  269. return $this;
  270. }
  271. /**
  272. * @return int|null
  273. */
  274. public function getAuthorId(): ?int
  275. {
  276. return $this->author_id;
  277. }
  278. /**
  279. * @param int $author_id
  280. *
  281. * @return $this
  282. */
  283. public function setAuthorId(int $author_id): self
  284. {
  285. $this->author_id = $author_id;
  286. return $this;
  287. }
  288. /**
  289. * @return int|null
  290. */
  291. public function getLyricyyyy(): ?int
  292. {
  293. return $this->lyricyyyy;
  294. }
  295. /**
  296. * @param int|null $lyricyyyy
  297. *
  298. * @return $this
  299. */
  300. public function setLyricyyyy(?int $lyricyyyy): self
  301. {
  302. $this->lyricyyyy = $lyricyyyy;
  303. return $this;
  304. }
  305. /**
  306. * @return int|null
  307. */
  308. public function getComposerId(): ?int
  309. {
  310. return $this->composer_id;
  311. }
  312. /**
  313. * @param int $composer_id
  314. *
  315. * @return $this
  316. */
  317. public function setComposerId(int $composer_id): self
  318. {
  319. $this->composer_id = $composer_id;
  320. return $this;
  321. }
  322. /**
  323. * @return int|null
  324. */
  325. public function getMusicyyyy(): ?int
  326. {
  327. return $this->musicyyyy;
  328. }
  329. /**
  330. * @param int|null $musicyyyy
  331. *
  332. * @return $this
  333. */
  334. public function setMusicyyyy(?int $musicyyyy): self
  335. {
  336. $this->musicyyyy = $musicyyyy;
  337. return $this;
  338. }
  339. /**
  340. * @return int|null
  341. */
  342. public function getArrangerId(): ?int
  343. {
  344. return $this->arranger_id;
  345. }
  346. /**
  347. * @param int $arranger_id
  348. *
  349. * @return $this
  350. */
  351. public function setArrangerId(int $arranger_id): self
  352. {
  353. $this->arranger_id = $arranger_id;
  354. return $this;
  355. }
  356. /**
  357. * @return int|null
  358. */
  359. public function getArrangedyyyy(): ?int
  360. {
  361. return $this->arrangedyyyy;
  362. }
  363. /**
  364. * @param int|null $arrangedyyyy
  365. *
  366. * @return $this
  367. */
  368. public function setArrangedyyyy(?int $arrangedyyyy): self
  369. {
  370. $this->arrangedyyyy = $arrangedyyyy;
  371. return $this;
  372. }
  373. /**
  374. * @return int|null
  375. */
  376. public function getTypeId(): ?int
  377. {
  378. return $this->type_id;
  379. }
  380. /**
  381. * @param int $type_id
  382. *
  383. * @return $this
  384. */
  385. public function setTypeId(int $type_id): self
  386. {
  387. $this->type_id = $type_id;
  388. return $this;
  389. }
  390. /**
  391. * @return Collection
  392. */
  393. public function getCategories(): Collection
  394. {
  395. return $this->category;
  396. }
  397. /**
  398. * @return string|null
  399. */
  400. public function getOthernotes(): ?string
  401. {
  402. return $this->othernotes;
  403. }
  404. /**
  405. * @param string|null $othernotes
  406. *
  407. * @return $this
  408. */
  409. public function setOthernotes(?string $othernotes): self
  410. {
  411. $this->othernotes = $othernotes;
  412. return $this;
  413. }
  414. /**
  415. * @return string|null
  416. */
  417. public function getText(): ?string
  418. {
  419. return $this->text;
  420. }
  421. /**
  422. * @param string|null $text
  423. *
  424. * @return $this
  425. */
  426. public function setText(?string $text): self
  427. {
  428. $this->text = $text;
  429. return $this;
  430. }
  431. /**
  432. * @return string|null
  433. */
  434. public function getCopyright(): ?string
  435. {
  436. return $this->copyright;
  437. }
  438. /**
  439. * @param string|null $copyright
  440. *
  441. * @return $this
  442. */
  443. public function setCopyright(?string $copyright): self
  444. {
  445. $this->copyright = $copyright;
  446. return $this;
  447. }
  448. /**
  449. * @return int|null
  450. */
  451. public function getHymnHitCount(): ?int
  452. {
  453. return $this->hymn_hit_count;
  454. }
  455. /**
  456. * @param int $hymn_hit_count
  457. *
  458. * @return $this
  459. */
  460. public function setHymnHitCount(int $hymn_hit_count): self
  461. {
  462. $this->hymn_hit_count = $hymn_hit_count;
  463. return $this;
  464. }
  465. /**
  466. * @return DateTime|null
  467. */
  468. public function getLastAccessed(): ?DateTime
  469. {
  470. return $this->last_accessed;
  471. }
  472. /**
  473. * @param DateTime $last_accessed
  474. *
  475. * @return $this
  476. */
  477. public function setLastAccessed(DateTime $last_accessed): self
  478. {
  479. $this->last_accessed = $last_accessed;
  480. return $this;
  481. }
  482. /**
  483. * @return DateTime|null
  484. */
  485. public function getCreatedAt(): ?DateTime
  486. {
  487. return $this->created_at;
  488. }
  489. /**
  490. * @param DateTime|null $created_at
  491. *
  492. * @return $this
  493. */
  494. public function setCreatedAt(?DateTime $created_at): self
  495. {
  496. $this->created_at = $created_at;
  497. return $this;
  498. }
  499. /**
  500. * @return DateTime|null
  501. */
  502. public function getUpdatedAt(): ?DateTime
  503. {
  504. return $this->updated_at;
  505. }
  506. /**
  507. * @param DateTime|null $updated_at
  508. *
  509. * @return $this
  510. */
  511. public function setUpdatedAt(?DateTime $updated_at): self
  512. {
  513. $this->updated_at = $updated_at;
  514. return $this;
  515. }
  516. /**
  517. * @return string
  518. */
  519. public function getFirstLetter(): string
  520. {
  521. $this->setFirstLetter();
  522. return $this->FirstLetter ?? 'A';
  523. }
  524. /**
  525. * @return void
  526. */
  527. public function setFirstLetter(): void
  528. {
  529. $this->FirstLetter = $this->getTitle()[0];
  530. }
  531. /**
  532. * @return string
  533. */
  534. public function getNextFL(): string
  535. {
  536. $this->setNextFL();
  537. return $this->nextFL ?? 'A';
  538. }
  539. /**
  540. * @return void
  541. */
  542. public function setNextFL(): void
  543. {
  544. $firstLetters = range('A', 'Z');
  545. $curLetterIndex = array_search($this->getFirstLetter(), $firstLetters, true);
  546. $this->nextFL = $curLetterIndex < 25 ? $firstLetters[ $curLetterIndex + 1 ] : 'A';
  547. }
  548. /**
  549. * @return string
  550. */
  551. public function getPrevSlug(): string
  552. {
  553. return $this->prevSlug;
  554. }
  555. /**
  556. * @param string $prevSlug
  557. */
  558. public function setPrevSlug(string $prevSlug): void
  559. {
  560. $this->prevSlug = $prevSlug;
  561. }
  562. /**
  563. * @return string
  564. */
  565. public function getNextSlug(): string
  566. {
  567. return $this->nextSlug;
  568. }
  569. /**
  570. * @param string $nextSlug
  571. */
  572. public function setNextSlug(string $nextSlug): void
  573. {
  574. $this->nextSlug = $nextSlug;
  575. }
  576. /**
  577. * @return Hymntypes
  578. */
  579. public function getType(): Hymntypes
  580. {
  581. return $this->type;
  582. }
  583. /**
  584. * @param Hymntypes $type
  585. *
  586. * @return $this
  587. */
  588. public function setType(Hymntypes $type): self
  589. {
  590. $this->type = $type;
  591. return $this;
  592. }
  593. public function getCategory(): ?Collection
  594. {
  595. return $this->category;
  596. }
  597. public function setCategory(?Collection $category): self
  598. {
  599. $this->category = $category;
  600. return $this;
  601. }
  602. /**
  603. * @return Authcomp
  604. */
  605. public function getAuthor(): Authcomp
  606. {
  607. return $this->author;
  608. }
  609. /**
  610. * @param Authcomp $author
  611. *
  612. * @return $this
  613. */
  614. public function setAuthor(Authcomp $author): self
  615. {
  616. $this->author = $author;
  617. return $this;
  618. }
  619. /**
  620. * @return Authcomp
  621. */
  622. public function getComposer(): Authcomp
  623. {
  624. return $this->composer;
  625. }
  626. /**
  627. * @param Authcomp $composer
  628. *
  629. * @return $this
  630. */
  631. public function setComposer(Authcomp $composer): self
  632. {
  633. $this->composer = $composer;
  634. return $this;
  635. }
  636. /**
  637. * @return Authcomp
  638. */
  639. public function getArranger(): Authcomp
  640. {
  641. return $this->arranger;
  642. }
  643. /**
  644. * @param Authcomp $arranger
  645. *
  646. * @return $this
  647. */
  648. public function setArranger(Authcomp $arranger): self
  649. {
  650. $this->arranger = $arranger;
  651. return $this;
  652. }
  653. /**
  654. * @return string|null
  655. */
  656. public function getPdf(): ?string
  657. {
  658. return $this->pdfFileName ?? null;
  659. }
  660. /**
  661. * @param string $pdfFileName
  662. */
  663. public function setPdf(string $pdfFileName): void
  664. {
  665. $this->pdfFileName = $pdfFileName;
  666. }
  667. /**
  668. * @return string|null
  669. */
  670. public function getMidi(): ?string
  671. {
  672. return $this->midiFileName ?? null;
  673. }
  674. /**
  675. * @param string $midiFileName
  676. */
  677. public function setMidi(string $midiFileName): void
  678. {
  679. $this->midiFileName = $midiFileName;
  680. }
  681. /**
  682. * @return string|null
  683. */
  684. public function getMp3(): ?string
  685. {
  686. return $this->mp3FileName ?? null;
  687. }
  688. /**
  689. * @param string $mp3FileName
  690. */
  691. public function setMp3(string $mp3FileName): void
  692. {
  693. $this->mp3FileName = $mp3FileName;
  694. }
  695. /**
  696. * @return string|null
  697. */
  698. public function getImg(): ?string
  699. {
  700. return $this->imgFileName ?? null;
  701. }
  702. /**
  703. * @param string $imgFileName
  704. */
  705. public function setImg(string $imgFileName): void
  706. {
  707. $this->imgFileName = $imgFileName;
  708. }
  709. /**
  710. * @return string|null
  711. */
  712. public function getXml(): ?string
  713. {
  714. return $this->xmlFileName ?? null;
  715. }
  716. /**
  717. * @param string $xmlFileName
  718. */
  719. public function setXml(string $xmlFileName): void
  720. {
  721. $this->xmlFileName = $xmlFileName;
  722. }
  723. /**
  724. * @return string
  725. */
  726. public function __toString(): string
  727. {
  728. return (string) $this->getTitle();
  729. }
  730. /**
  731. * @return int|null
  732. */
  733. public function getScorePageCount(): ?int
  734. {
  735. return $this->score_page_count;
  736. }
  737. /**
  738. * @param int $score_page_count
  739. * @return $this
  740. */
  741. public function setScorePageCount(int $score_page_count): self
  742. {
  743. $this->score_page_count = $score_page_count;
  744. return $this;
  745. }
  746. }