<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Hymns
*
* @ORM\Table(name="hymns")
* @ORM\Entity(repositoryClass="App\Repository\HymnsRepository")
*/
class Hymns
{
/**
* @var int
*
* @ORM\Column(type="integer", name="id", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id = 0;
/**
* @var string
*
* @ORM\Column(type="string", length=255, nullable=false, name="title")
*/
private string $title = '';
/**
* @Gedmo\Slug(fields={"title","slug"})
* @ORM\Column(type="string", unique=true, length=255, nullable=false)
*/
private string $slug = '';
/**
* @var int
*
* @ORM\Column(type="integer", nullable=false, name="author_id")
*/
private int $author_id = 713;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="LyricYYYY")
*/
private ?int $lyricyyyy;
/**
* @var int
*
* @ORM\Column(type="integer", nullable=false, name="composer_id")
*/
private int $composer_id = 713;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="MusicYYYY")
*/
private ?int $musicyyyy;
/**
* @var int
*
* @ORM\Column(type="integer", nullable=false, name="arranger_id")
*/
private int $arranger_id = 713;
/**
* @var int|null
*
* @ORM\Column(type="integer", nullable=true, name="ArrangedYYYY")
*/
private ?int $arrangedyyyy;
/**
* @var int
*
* @ORM\Column(type="integer", nullable=false, name="type_id")
* @ORM\JoinColumn(nullable=false, referencedColumnName="id")
*/
private int $type_id = 1;
/**
* @var string|null
*
* @ORM\Column(type="text", length=65535, nullable=true, name="OtherNotes")
*/
private ?string $othernotes;
/**
* @var string|null
*
* @ORM\Column(type="text", length=65535, nullable=true, name="text")
*/
private ?string $text;
/**
* @var string|null
*
* @ORM\Column(type="string", length=200, nullable=true, name="copyright")
*/
private ?string $copyright;
/**
* @ORM\Column(type="integer", nullable=false, name="score_page_count")
*/
private int $score_page_count = 1;
/**
* @var int
*
* @ORM\Column(type="integer", nullable=false, name="hymn_hit_count")
*/
private int $hymn_hit_count = 0;
/**
* @var DateTime
*
* @ORM\Column(type="datetime", nullable=false, name="last_accessed", options={"default":"CURRENT_TIMESTAMP"})
*/
private DateTime $last_accessed;
/**
* @var DateTime|null
*
* @ORM\Column(type="datetime", nullable=true, name="created_at")
*/
private ?DateTime $created_at;
/**
* @var DateTime|null
*
* @ORM\Column(type="datetime", nullable=true, name="updated_at")
*/
private ?DateTime $updated_at;
/**
* @var string
*/
private string $FirstLetter;
/**
* @var string
*/
private string $nextFL;
/**
* @var string
*/
private string $prevSlug;
/**
* @var string
*/
private string $nextSlug;
/**
* @var Hymntypes|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Hymntypes", inversedBy="hymns")
* @ORM\JoinColumn(nullable=false, referencedColumnName="id")
*/
private ?Hymntypes $type;
/**
* @var Collection|null
*
* @ORM\ManyToMany(targetEntity="App\Entity\HymnCategory", inversedBy="hymns")
* @ORM\JoinColumn(nullable=true, referencedColumnName="id")
*/
private ?Collection $category;
/**
* @var Authcomp|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="auth_hymns")
* @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
*/
private ?Authcomp $author;
/**
* @var Authcomp|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="comp_hymns")
* @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
*/
private ?Authcomp $composer;
/**
* @var Authcomp|null
*
* @ORM\ManyToOne(targetEntity="App\Entity\Authcomp", inversedBy="arr_hymns")
* @ORM\JoinColumn(nullable=true, referencedColumnName="ID")
*/
private ?Authcomp $arranger;
/**
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"application/pdf", "application/x-pdf"},
* mimeTypesMessage = "Please upload a valid PDF"
* )
* @var string|null
*/
private ?string $pdfFileName;
/**
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"application/jpg", "application/jpeg"},
* mimeTypesMessage = "Please upload a valid Hymn image"
* )
* @var string|null
*/
private ?string $imgFileName;
/**
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"application/midi", "application/wav", "application/mp3"},
* mimeTypesMessage = "Please upload a valid audio file"
* )
* @var string|null
*/
private ?string $midiFileName;
/**
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"audio/mpeg"},
* mimeTypesMessage = "Please upload a valid audio file"
* )
* @var string|null
*/
private ?string $mp3FileName;
/**
* @Assert\File(
* maxSize = "1024k",
* mimeTypes = {"application/xml"},
* mimeTypesMessage = "Please upload a valid Music XML file"
* )
* @var string|null
*/
private ?string $xmlFileName;
/**
* Hymns constructor.
* @throws Exception
*/
public function __construct()
{
$this->setLastAccessed(new DateTime('now'));
$this->copyright = 'Arr. Copyright © ' . date('Y') . ' Manz Music Publishing';
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return string|null
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param string $title
*
* @return $this
*/
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return string|null
*/
public function getSlug(): ?string
{
return $this->slug;
}
/**
* @param string $slug
*
* @return $this
*/
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return int|null
*/
public function getAuthorId(): ?int
{
return $this->author_id;
}
/**
* @param int $author_id
*
* @return $this
*/
public function setAuthorId(int $author_id): self
{
$this->author_id = $author_id;
return $this;
}
/**
* @return int|null
*/
public function getLyricyyyy(): ?int
{
return $this->lyricyyyy;
}
/**
* @param int|null $lyricyyyy
*
* @return $this
*/
public function setLyricyyyy(?int $lyricyyyy): self
{
$this->lyricyyyy = $lyricyyyy;
return $this;
}
/**
* @return int|null
*/
public function getComposerId(): ?int
{
return $this->composer_id;
}
/**
* @param int $composer_id
*
* @return $this
*/
public function setComposerId(int $composer_id): self
{
$this->composer_id = $composer_id;
return $this;
}
/**
* @return int|null
*/
public function getMusicyyyy(): ?int
{
return $this->musicyyyy;
}
/**
* @param int|null $musicyyyy
*
* @return $this
*/
public function setMusicyyyy(?int $musicyyyy): self
{
$this->musicyyyy = $musicyyyy;
return $this;
}
/**
* @return int|null
*/
public function getArrangerId(): ?int
{
return $this->arranger_id;
}
/**
* @param int $arranger_id
*
* @return $this
*/
public function setArrangerId(int $arranger_id): self
{
$this->arranger_id = $arranger_id;
return $this;
}
/**
* @return int|null
*/
public function getArrangedyyyy(): ?int
{
return $this->arrangedyyyy;
}
/**
* @param int|null $arrangedyyyy
*
* @return $this
*/
public function setArrangedyyyy(?int $arrangedyyyy): self
{
$this->arrangedyyyy = $arrangedyyyy;
return $this;
}
/**
* @return int|null
*/
public function getTypeId(): ?int
{
return $this->type_id;
}
/**
* @param int $type_id
*
* @return $this
*/
public function setTypeId(int $type_id): self
{
$this->type_id = $type_id;
return $this;
}
/**
* @return Collection
*/
public function getCategories(): Collection
{
return $this->category;
}
/**
* @return string|null
*/
public function getOthernotes(): ?string
{
return $this->othernotes;
}
/**
* @param string|null $othernotes
*
* @return $this
*/
public function setOthernotes(?string $othernotes): self
{
$this->othernotes = $othernotes;
return $this;
}
/**
* @return string|null
*/
public function getText(): ?string
{
return $this->text;
}
/**
* @param string|null $text
*
* @return $this
*/
public function setText(?string $text): self
{
$this->text = $text;
return $this;
}
/**
* @return string|null
*/
public function getCopyright(): ?string
{
return $this->copyright;
}
/**
* @param string|null $copyright
*
* @return $this
*/
public function setCopyright(?string $copyright): self
{
$this->copyright = $copyright;
return $this;
}
/**
* @return int|null
*/
public function getHymnHitCount(): ?int
{
return $this->hymn_hit_count;
}
/**
* @param int $hymn_hit_count
*
* @return $this
*/
public function setHymnHitCount(int $hymn_hit_count): self
{
$this->hymn_hit_count = $hymn_hit_count;
return $this;
}
/**
* @return DateTime|null
*/
public function getLastAccessed(): ?DateTime
{
return $this->last_accessed;
}
/**
* @param DateTime $last_accessed
*
* @return $this
*/
public function setLastAccessed(DateTime $last_accessed): self
{
$this->last_accessed = $last_accessed;
return $this;
}
/**
* @return DateTime|null
*/
public function getCreatedAt(): ?DateTime
{
return $this->created_at;
}
/**
* @param DateTime|null $created_at
*
* @return $this
*/
public function setCreatedAt(?DateTime $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* @return DateTime|null
*/
public function getUpdatedAt(): ?DateTime
{
return $this->updated_at;
}
/**
* @param DateTime|null $updated_at
*
* @return $this
*/
public function setUpdatedAt(?DateTime $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return string
*/
public function getFirstLetter(): string
{
$this->setFirstLetter();
return $this->FirstLetter ?? 'A';
}
/**
* @return void
*/
public function setFirstLetter(): void
{
$this->FirstLetter = $this->getTitle()[0];
}
/**
* @return string
*/
public function getNextFL(): string
{
$this->setNextFL();
return $this->nextFL ?? 'A';
}
/**
* @return void
*/
public function setNextFL(): void
{
$firstLetters = range('A', 'Z');
$curLetterIndex = array_search($this->getFirstLetter(), $firstLetters, true);
$this->nextFL = $curLetterIndex < 25 ? $firstLetters[ $curLetterIndex + 1 ] : 'A';
}
/**
* @return string
*/
public function getPrevSlug(): string
{
return $this->prevSlug;
}
/**
* @param string $prevSlug
*/
public function setPrevSlug(string $prevSlug): void
{
$this->prevSlug = $prevSlug;
}
/**
* @return string
*/
public function getNextSlug(): string
{
return $this->nextSlug;
}
/**
* @param string $nextSlug
*/
public function setNextSlug(string $nextSlug): void
{
$this->nextSlug = $nextSlug;
}
/**
* @return Hymntypes
*/
public function getType(): Hymntypes
{
return $this->type;
}
/**
* @param Hymntypes $type
*
* @return $this
*/
public function setType(Hymntypes $type): self
{
$this->type = $type;
return $this;
}
public function getCategory(): ?Collection
{
return $this->category;
}
public function setCategory(?Collection $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Authcomp
*/
public function getAuthor(): Authcomp
{
return $this->author;
}
/**
* @param Authcomp $author
*
* @return $this
*/
public function setAuthor(Authcomp $author): self
{
$this->author = $author;
return $this;
}
/**
* @return Authcomp
*/
public function getComposer(): Authcomp
{
return $this->composer;
}
/**
* @param Authcomp $composer
*
* @return $this
*/
public function setComposer(Authcomp $composer): self
{
$this->composer = $composer;
return $this;
}
/**
* @return Authcomp
*/
public function getArranger(): Authcomp
{
return $this->arranger;
}
/**
* @param Authcomp $arranger
*
* @return $this
*/
public function setArranger(Authcomp $arranger): self
{
$this->arranger = $arranger;
return $this;
}
/**
* @return string|null
*/
public function getPdf(): ?string
{
return $this->pdfFileName ?? null;
}
/**
* @param string $pdfFileName
*/
public function setPdf(string $pdfFileName): void
{
$this->pdfFileName = $pdfFileName;
}
/**
* @return string|null
*/
public function getMidi(): ?string
{
return $this->midiFileName ?? null;
}
/**
* @param string $midiFileName
*/
public function setMidi(string $midiFileName): void
{
$this->midiFileName = $midiFileName;
}
/**
* @return string|null
*/
public function getMp3(): ?string
{
return $this->mp3FileName ?? null;
}
/**
* @param string $mp3FileName
*/
public function setMp3(string $mp3FileName): void
{
$this->mp3FileName = $mp3FileName;
}
/**
* @return string|null
*/
public function getImg(): ?string
{
return $this->imgFileName ?? null;
}
/**
* @param string $imgFileName
*/
public function setImg(string $imgFileName): void
{
$this->imgFileName = $imgFileName;
}
/**
* @return string|null
*/
public function getXml(): ?string
{
return $this->xmlFileName ?? null;
}
/**
* @param string $xmlFileName
*/
public function setXml(string $xmlFileName): void
{
$this->xmlFileName = $xmlFileName;
}
/**
* @return string
*/
public function __toString(): string
{
return (string) $this->getTitle();
}
/**
* @return int|null
*/
public function getScorePageCount(): ?int
{
return $this->score_page_count;
}
/**
* @param int $score_page_count
* @return $this
*/
public function setScorePageCount(int $score_page_count): self
{
$this->score_page_count = $score_page_count;
return $this;
}
}