From aead9915bce6632728155827bed141fc665a98c1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 15 Apr 2024 23:44:36 -0400 Subject: [PATCH] add entities and repos --- src/Entity/Notes.php | 93 +++++++++++++++++++++++ src/Entity/Series.php | 102 ++++++++++++++++++++++++++ src/Entity/Speaker.php | 87 ++++++++++++++++++++++ src/Entity/Template.php | 93 +++++++++++++++++++++++ src/Repository/NotesRepository.php | 48 ++++++++++++ src/Repository/SeriesRepository.php | 48 ++++++++++++ src/Repository/SpeakerRepository.php | 48 ++++++++++++ src/Repository/TemplateRepository.php | 48 ++++++++++++ 8 files changed, 567 insertions(+) create mode 100644 src/Entity/Notes.php create mode 100644 src/Entity/Series.php create mode 100644 src/Entity/Speaker.php create mode 100644 src/Entity/Template.php create mode 100644 src/Repository/NotesRepository.php create mode 100644 src/Repository/SeriesRepository.php create mode 100644 src/Repository/SpeakerRepository.php create mode 100644 src/Repository/TemplateRepository.php diff --git a/src/Entity/Notes.php b/src/Entity/Notes.php new file mode 100644 index 0000000..02d461c --- /dev/null +++ b/src/Entity/Notes.php @@ -0,0 +1,93 @@ +id; + } + + public function getTitle(): ?string + { + return $this->title; + } + + public function setTitle(string $title): static + { + $this->title = $title; + + return $this; + } + + public function getSpeaker(): ?Speaker + { + return $this->speaker; + } + + public function setSpeaker(?Speaker $speaker): static + { + $this->speaker = $speaker; + + return $this; + } + + public function getSeries(): ?Series + { + return $this->series; + } + + public function setSeries(?Series $series): static + { + $this->series = $series; + + return $this; + } + + public function getText(): ?string + { + return $this->text; + } + + public function setText(?string $text): static + { + $this->text = $text; + + return $this; + } + + public function jsonSerialize(): array + { + return [ + 'id' => $this->id, + 'title' => $this->title, + 'speaker' => $this->speaker, + 'series' => $this->series, + 'text' => $this->text, + ]; + } +} diff --git a/src/Entity/Series.php b/src/Entity/Series.php new file mode 100644 index 0000000..0057ed5 --- /dev/null +++ b/src/Entity/Series.php @@ -0,0 +1,102 @@ + + */ + #[ORM\OneToMany(targetEntity: Notes::class, mappedBy: 'series')] + private Collection $notes; + + #[ORM\ManyToOne(inversedBy: 'series')] + private ?Template $template = null; + + public function __construct() + { + $this->notes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection + */ + public function getNotes(): Collection + { + return $this->notes; + } + + public function addNote(Notes $note): static + { + if (!$this->notes->contains($note)) { + $this->notes->add($note); + $note->setSeries($this); + } + + return $this; + } + + public function removeNote(Notes $note): static + { + if ($this->notes->removeElement($note)) { + // set the owning side to null (unless already changed) + if ($note->getSeries() === $this) { + $note->setSeries(null); + } + } + + return $this; + } + + public function getTemplate(): ?Template + { + return $this->template; + } + + public function setTemplate(?Template $template): static + { + $this->template = $template; + + return $this; + } + + public function jsonSerialize(): array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + ]; + } +} diff --git a/src/Entity/Speaker.php b/src/Entity/Speaker.php new file mode 100644 index 0000000..1dbadf1 --- /dev/null +++ b/src/Entity/Speaker.php @@ -0,0 +1,87 @@ + + */ + #[ORM\OneToMany(targetEntity: Notes::class, mappedBy: 'speaker')] + private Collection $notes; + + public function __construct() + { + $this->notes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection + */ + public function getNotes(): Collection + { + return $this->notes; + } + + public function addNote(Notes $note): static + { + if (!$this->notes->contains($note)) { + $this->notes->add($note); + $note->setSpeaker($this); + } + + return $this; + } + + public function removeNote(Notes $note): static + { + if ($this->notes->removeElement($note)) { + // set the owning side to null (unless already changed) + if ($note->getSpeaker() === $this) { + $note->setSpeaker(null); + } + } + + return $this; + } + + public function jsonSerialize(): array + { + return [ + 'id' => $this->id, + 'name' => $this->name, + ]; + } +} diff --git a/src/Entity/Template.php b/src/Entity/Template.php new file mode 100644 index 0000000..43478de --- /dev/null +++ b/src/Entity/Template.php @@ -0,0 +1,93 @@ + + */ + #[ORM\OneToMany(targetEntity: Series::class, mappedBy: 'template')] + private Collection $series; + + public function __construct() + { + $this->series = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getValue(): ?string + { + return $this->value; + } + + public function setValue(string $value): static + { + $this->value = $value; + + return $this; + } + + /** + * @return Collection + */ + public function getSeries(): Collection + { + return $this->series; + } + + public function addSeries(Series $series): static + { + if (!$this->series->contains($series)) { + $this->series->add($series); + $series->setTemplate($this); + } + + return $this; + } + + public function removeSeries(Series $series): static + { + if ($this->series->removeElement($series)) { + // set the owning side to null (unless already changed) + if ($series->getTemplate() === $this) { + $series->setTemplate(null); + } + } + + return $this; + } +} diff --git a/src/Repository/NotesRepository.php b/src/Repository/NotesRepository.php new file mode 100644 index 0000000..4219df3 --- /dev/null +++ b/src/Repository/NotesRepository.php @@ -0,0 +1,48 @@ + + * + * @method Notes|null find($id, $lockMode = null, $lockVersion = null) + * @method Notes|null findOneBy(array $criteria, array $orderBy = null) + * @method Notes[] findAll() + * @method Notes[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class NotesRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Notes::class); + } + + // /** + // * @return Notes[] Returns an array of Notes objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('n') + // ->andWhere('n.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('n.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Notes + // { + // return $this->createQueryBuilder('n') + // ->andWhere('n.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/SeriesRepository.php b/src/Repository/SeriesRepository.php new file mode 100644 index 0000000..d79102b --- /dev/null +++ b/src/Repository/SeriesRepository.php @@ -0,0 +1,48 @@ + + * + * @method Series|null find($id, $lockMode = null, $lockVersion = null) + * @method Series|null findOneBy(array $criteria, array $orderBy = null) + * @method Series[] findAll() + * @method Series[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SeriesRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Series::class); + } + + // /** + // * @return Series[] Returns an array of Series objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Series + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/SpeakerRepository.php b/src/Repository/SpeakerRepository.php new file mode 100644 index 0000000..546a9b5 --- /dev/null +++ b/src/Repository/SpeakerRepository.php @@ -0,0 +1,48 @@ + + * + * @method Speaker|null find($id, $lockMode = null, $lockVersion = null) + * @method Speaker|null findOneBy(array $criteria, array $orderBy = null) + * @method Speaker[] findAll() + * @method Speaker[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SpeakerRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Speaker::class); + } + + // /** + // * @return Speaker[] Returns an array of Speaker objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Speaker + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/TemplateRepository.php b/src/Repository/TemplateRepository.php new file mode 100644 index 0000000..638f973 --- /dev/null +++ b/src/Repository/TemplateRepository.php @@ -0,0 +1,48 @@ + + * + * @method Template|null find($id, $lockMode = null, $lockVersion = null) + * @method Template|null findOneBy(array $criteria, array $orderBy = null) + * @method Template[] findAll() + * @method Template[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class TemplateRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Template::class); + } + + // /** + // * @return Template[] Returns an array of Template objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('t') + // ->andWhere('t.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('t.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Template + // { + // return $this->createQueryBuilder('t') + // ->andWhere('t.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}