add entities and repos
This commit is contained in:
parent
7114b60271
commit
aead9915bc
93
src/Entity/Notes.php
Normal file
93
src/Entity/Notes.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\NotesRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: NotesRepository::class)]
|
||||
class Notes implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notes')]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private ?Speaker $speaker = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notes')]
|
||||
private ?Series $series = null;
|
||||
|
||||
#[ORM\Column(length: 4096)]
|
||||
private ?string $text = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->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,
|
||||
];
|
||||
}
|
||||
}
|
102
src/Entity/Series.php
Normal file
102
src/Entity/Series.php
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\SeriesRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SeriesRepository::class)]
|
||||
class Series implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 64)]
|
||||
private ?string $name = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Notes>
|
||||
*/
|
||||
#[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<int, Notes>
|
||||
*/
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
87
src/Entity/Speaker.php
Normal file
87
src/Entity/Speaker.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\SpeakerRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SpeakerRepository::class)]
|
||||
class Speaker implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Notes>
|
||||
*/
|
||||
#[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<int, Notes>
|
||||
*/
|
||||
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,
|
||||
];
|
||||
}
|
||||
}
|
93
src/Entity/Template.php
Normal file
93
src/Entity/Template.php
Normal file
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\TemplateRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TemplateRepository::class)]
|
||||
class Template
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 2049)]
|
||||
private ?string $value = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Series>
|
||||
*/
|
||||
#[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<int, Series>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
48
src/Repository/NotesRepository.php
Normal file
48
src/Repository/NotesRepository.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Notes;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Notes>
|
||||
*
|
||||
* @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()
|
||||
// ;
|
||||
// }
|
||||
}
|
48
src/Repository/SeriesRepository.php
Normal file
48
src/Repository/SeriesRepository.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Series;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Series>
|
||||
*
|
||||
* @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()
|
||||
// ;
|
||||
// }
|
||||
}
|
48
src/Repository/SpeakerRepository.php
Normal file
48
src/Repository/SpeakerRepository.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Speaker;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Speaker>
|
||||
*
|
||||
* @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()
|
||||
// ;
|
||||
// }
|
||||
}
|
48
src/Repository/TemplateRepository.php
Normal file
48
src/Repository/TemplateRepository.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Template;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Template>
|
||||
*
|
||||
* @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()
|
||||
// ;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user