Entities & Repos
This commit is contained in:
parent
21f014d08d
commit
658b021962
0
src/Entity/.gitignore
vendored
Normal file
0
src/Entity/.gitignore
vendored
Normal file
190
src/Entity/Bible.php
Normal file
190
src/Entity/Bible.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
use App\Repository\BibleRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: BibleRepository::class)]
|
||||
class Bible implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $book = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $chapter = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $verse = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $content = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?int $book_index = null;
|
||||
|
||||
#[ORM\Column(length: 20, nullable: true)]
|
||||
private ?string $label = null;
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getBook(): ?string
|
||||
{
|
||||
return $this->book;
|
||||
}
|
||||
|
||||
public function setBook(string $book): static
|
||||
{
|
||||
$this->book = $book;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChapter(): ?int
|
||||
{
|
||||
return $this->chapter;
|
||||
}
|
||||
|
||||
public function setChapter(int $chapter): static
|
||||
{
|
||||
$this->chapter = $chapter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getVerse(): ?int
|
||||
{
|
||||
return $this->verse;
|
||||
}
|
||||
|
||||
public function setVerse(int $verse): static
|
||||
{
|
||||
$this->verse = $verse;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(?string $content): static
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBookIndex(): ?int
|
||||
{
|
||||
return $this->book_index;
|
||||
}
|
||||
|
||||
public function setBookIndex(int $book_index): static
|
||||
{
|
||||
$this->book_index = $book_index;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(?string $label): static
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function findBook(string $reference): string
|
||||
{
|
||||
$book = '';
|
||||
$tmp = explode(' ', $reference);
|
||||
$book = "{$tmp[0]}";
|
||||
|
||||
if(count($tmp) > 2) {
|
||||
$book = "{$tmp[0]}{$tmp[1]}";
|
||||
}
|
||||
|
||||
return $book;
|
||||
}
|
||||
|
||||
public static function findChapter(string $reference): string
|
||||
{
|
||||
$chapter = '';
|
||||
$tmp = explode(' ', $reference);
|
||||
|
||||
if(count($tmp) > 2) {
|
||||
$passage = $tmp[2];
|
||||
} else {
|
||||
$passage = $tmp[1];
|
||||
}
|
||||
|
||||
$tmp = explode(':', $passage);
|
||||
$chapter = $tmp[0];
|
||||
|
||||
return $chapter;
|
||||
}
|
||||
|
||||
public static function findVerse(string $reference): int|array|bool
|
||||
{
|
||||
$verses = null;
|
||||
$semicolon = strpos($reference, ':');
|
||||
if ($semicolon === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tmp = substr($reference, $semicolon + 1);
|
||||
|
||||
if(strpos($tmp, '-') !== false) {
|
||||
$verses = explode('-', $tmp);
|
||||
} else {
|
||||
$verses = (int) $tmp;
|
||||
}
|
||||
|
||||
return $verses;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'book' => $this->getBook(),
|
||||
'chapter' => $this->getChapter(),
|
||||
'verse' => $this->getVerse(),
|
||||
'content' => $this->getContent(),
|
||||
'book_index' => $this->getBookIndex(),
|
||||
'label' => $this->getLabel(),
|
||||
];
|
||||
}
|
||||
}
|
196
src/Entity/Note.php
Normal file
196
src/Entity/Note.php
Normal file
@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\NoteRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: NoteRepository::class)]
|
||||
class Note implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $title = null;
|
||||
|
||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||
private ?\DateTimeInterface $date = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $passage = null;
|
||||
|
||||
#[ORM\Column(type: Types::JSON, nullable: true)]
|
||||
private ?array $refs = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $text = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notes')]
|
||||
private ?Speaker $speaker = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notes')]
|
||||
private ?Series $series = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'notes')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): static
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeInterface
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTimeInterface $date): static
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPassage(): ?string
|
||||
{
|
||||
return $this->passage;
|
||||
}
|
||||
|
||||
public function setPassage(string $passage): static
|
||||
{
|
||||
$this->passage = $passage;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRefs(): ?array
|
||||
{
|
||||
return $this->refs;
|
||||
}
|
||||
|
||||
public function setRefs(?array $refs): static
|
||||
{
|
||||
$this->refs = $refs;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addRef(Reference $ref): static
|
||||
{
|
||||
$this->refs[] = $ref;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getText(): ?string
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
public function setText(?string $text): static
|
||||
{
|
||||
$this->text = $text;
|
||||
|
||||
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 getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function toLink(): string
|
||||
{
|
||||
return "<a href='#' onclick=\"retrieveNote('{$this->id}')\">".
|
||||
$this->title.
|
||||
"</a>";
|
||||
}
|
||||
|
||||
public function toTableRow(): string
|
||||
{
|
||||
return "<tr>".
|
||||
"<td>{$this->toLink()}</td>".
|
||||
"<td>{$this->speaker->getName()}</td>".
|
||||
"<td>{$this->passage}</td>".
|
||||
"<td>{$this->date->format('M j, Y')}</td>".
|
||||
"</tr>";
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'title' => $this->getTitle(),
|
||||
'date' => $this->getDate(),
|
||||
'passage' => $this->getPassage(),
|
||||
'refs' => $this->getRefs(),
|
||||
'text' => $this->getText(),
|
||||
'speaker' => $this->getSpeaker(),
|
||||
'series' => $this->getSeries(),
|
||||
'user' => $this->getUser(),
|
||||
];
|
||||
}
|
||||
}
|
124
src/Entity/Reference.php
Normal file
124
src/Entity/Reference.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\ReferenceRepository;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ReferenceRepository::class)]
|
||||
class Reference implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $type = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $label = null;
|
||||
|
||||
#[ORM\Column(nullable: true)]
|
||||
private ?int $ndx = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||
private ?string $content = null;
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): static
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel(string $label): static
|
||||
{
|
||||
$this->label = $label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNdx(): ?int
|
||||
{
|
||||
return $this->ndx;
|
||||
}
|
||||
|
||||
public function setNdx(int $ndx): static
|
||||
{
|
||||
$this->ndx = $ndx;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(?string $content): static
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'name' => $this->name,
|
||||
'label' => $this->label,
|
||||
'ndx' => $this->ndx,
|
||||
'content' => $this->content,
|
||||
];
|
||||
}
|
||||
}
|
134
src/Entity/Series.php
Normal file
134
src/Entity/Series.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?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;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SeriesRepository::class)]
|
||||
class Series implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'series')]
|
||||
private ?User $user = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'series')]
|
||||
private ?Template $template = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Note>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'series')]
|
||||
private Collection $notes;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->notes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTemplate(): ?Template
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
public function setTemplate(?Template $template): static
|
||||
{
|
||||
$this->template = $template;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Note>
|
||||
*/
|
||||
public function getNotes(): Collection
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
public function addNote(Note $note): static
|
||||
{
|
||||
if (!$this->notes->contains($note)) {
|
||||
$this->notes->add($note);
|
||||
$note->setSeries($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeNote(Note $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 jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
'note_count' => count($this->getNotes()),
|
||||
'template' => $this->getTemplate(),
|
||||
];
|
||||
}
|
||||
}
|
118
src/Entity/Speaker.php
Normal file
118
src/Entity/Speaker.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?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;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: SpeakerRepository::class)]
|
||||
class Speaker implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'speakers')]
|
||||
private ?User $user = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Note>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'speaker')]
|
||||
private Collection $notes;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->notes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Note>
|
||||
*/
|
||||
public function getNotes(): Collection
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
public function addNote(Note $note): static
|
||||
{
|
||||
if (!$this->notes->contains($note)) {
|
||||
$this->notes->add($note);
|
||||
$note->setSpeaker($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeNote(Note $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->getId(),
|
||||
'name' => $this->getName(),
|
||||
'note_count' => count($this->notes),
|
||||
];
|
||||
}
|
||||
}
|
134
src/Entity/Template.php
Normal file
134
src/Entity/Template.php
Normal file
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\TemplateRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: TemplateRepository::class)]
|
||||
class Template implements JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
#[ORM\Column(type: Types::TEXT)]
|
||||
private ?string $content = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Series>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Series::class, mappedBy: 'template')]
|
||||
private Collection $series;
|
||||
|
||||
#[ORM\ManyToOne(inversedBy: 'templates')]
|
||||
private ?User $user = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->series = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContent(): ?string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setContent(string $content): static
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function setUser(?User $user): static
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
'content' => $this->getContent(),
|
||||
];
|
||||
}
|
||||
}
|
302
src/Entity/User.php
Normal file
302
src/Entity/User.php
Normal file
@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
use App\Repository\UserRepository;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Bridge\Doctrine\Types\UuidType;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
|
||||
#[ORM\Entity(repositoryClass: UserRepository::class)]
|
||||
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
|
||||
class User implements UserInterface, PasswordAuthenticatedUserInterface, JsonSerializable
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: UuidType::NAME, unique: true)]
|
||||
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
||||
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
||||
private ?Uuid $id = null;
|
||||
|
||||
#[ORM\Column(length: 180)]
|
||||
private ?string $email = null;
|
||||
|
||||
/**
|
||||
* @var list<string> The user roles
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private array $roles = [];
|
||||
|
||||
/**
|
||||
* @var string The hashed password
|
||||
*/
|
||||
#[ORM\Column]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\Column(length: 255)]
|
||||
private ?string $name = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Series>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Series::class, mappedBy: 'user')]
|
||||
private Collection $series;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Speaker>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Speaker::class, mappedBy: 'user')]
|
||||
private Collection $speakers;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Template>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Template::class, mappedBy: 'user')]
|
||||
private Collection $templates;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Note>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'user')]
|
||||
private Collection $notes;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->series = new ArrayCollection();
|
||||
$this->speakers = new ArrayCollection();
|
||||
$this->templates = new ArrayCollection();
|
||||
$this->notes = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?Uuid
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(?Uuid $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function idFromString(string $id): Uuid
|
||||
{
|
||||
return Uuid::fromString($id);
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A visual identifier that represents this user.
|
||||
*
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function getUserIdentifier(): string
|
||||
{
|
||||
return (string) $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getRoles(): array
|
||||
{
|
||||
$roles = $this->roles;
|
||||
// guarantee every user at least has ROLE_USER
|
||||
$roles[] = 'ROLE_USER';
|
||||
|
||||
return array_unique($roles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $roles
|
||||
*/
|
||||
public function setRoles(array $roles): static
|
||||
{
|
||||
$this->roles = $roles;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see PasswordAuthenticatedUserInterface
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setPassword(string $password): static
|
||||
{
|
||||
$this->password = $password;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
public function eraseCredentials(): void
|
||||
{
|
||||
// If you store any temporary, sensitive data on the user, clear it here
|
||||
// $this->plainPassword = null;
|
||||
}
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): static
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
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->setUser($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->getUser() === $this) {
|
||||
$series->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Speaker>
|
||||
*/
|
||||
public function getSpeakers(): Collection
|
||||
{
|
||||
return $this->speakers;
|
||||
}
|
||||
|
||||
public function addSpeaker(Speaker $speaker): static
|
||||
{
|
||||
if (!$this->speakers->contains($speaker)) {
|
||||
$this->speakers->add($speaker);
|
||||
$speaker->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeSpeaker(Speaker $speaker): static
|
||||
{
|
||||
if ($this->speakers->removeElement($speaker)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($speaker->getUser() === $this) {
|
||||
$speaker->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Template>
|
||||
*/
|
||||
public function getTemplates(): Collection
|
||||
{
|
||||
return $this->templates;
|
||||
}
|
||||
|
||||
public function addTemplate(Template $template): static
|
||||
{
|
||||
if (!$this->templates->contains($template)) {
|
||||
$this->templates->add($template);
|
||||
$template->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeTemplate(Template $template): static
|
||||
{
|
||||
if ($this->templates->removeElement($template)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($template->getUser() === $this) {
|
||||
$template->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Note>
|
||||
*/
|
||||
public function getNotes(): Collection
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
public function addNote(Note $note): static
|
||||
{
|
||||
if (!$this->notes->contains($note)) {
|
||||
$this->notes->add($note);
|
||||
$note->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeNote(Note $note): static
|
||||
{
|
||||
if ($this->notes->removeElement($note)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($note->getUser() === $this) {
|
||||
$note->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'email' => $this->email,
|
||||
'name' => $this->name,
|
||||
];
|
||||
}
|
||||
}
|
57
src/Repository/BibleRepository.php
Normal file
57
src/Repository/BibleRepository.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Bible;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Bible>
|
||||
*/
|
||||
class BibleRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Bible::class);
|
||||
}
|
||||
|
||||
public function findRange(Bible $bible, array $passage): array
|
||||
{
|
||||
return $this->createQueryBuilder('b')
|
||||
->andWhere('b.book = :book')
|
||||
->andWhere('b.chapter = :chapter')
|
||||
->andWhere('b.verse BETWEEN :verseStart AND :verseEnd')
|
||||
->setParameter('book', $bible->getBook())
|
||||
->setParameter('chapter', $bible->getChapter())
|
||||
->setParameter('verseStart', $passage[0])
|
||||
->setParameter('verseEnd', $passage[1])
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Bible[] Returns an array of Bible objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('b.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Bible
|
||||
// {
|
||||
// return $this->createQueryBuilder('b')
|
||||
// ->andWhere('b.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
56
src/Repository/NoteRepository.php
Normal file
56
src/Repository/NoteRepository.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Note;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Note>
|
||||
*/
|
||||
class NoteRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Note::class);
|
||||
}
|
||||
|
||||
public function getLast4Notes(?User $user): array
|
||||
{
|
||||
$ret = $this->createQueryBuilder('n')
|
||||
->where('n.user = :user')
|
||||
->setParameter('user', (string) $user->getId())
|
||||
->orderBy('n.date', 'DESC')
|
||||
->setMaxResults(4)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Note[] Returns an array of Note 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): ?Note
|
||||
// {
|
||||
// return $this->createQueryBuilder('n')
|
||||
// ->andWhere('n.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
52
src/Repository/ReferenceRepository.php
Normal file
52
src/Repository/ReferenceRepository.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Reference;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Reference>
|
||||
*/
|
||||
class ReferenceRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Reference::class);
|
||||
}
|
||||
|
||||
public function findByType(string $type): array
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->andWhere('r.type = :val')
|
||||
->setParameter('val', $type)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Reference[] Returns an array of Reference objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('r.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Reference
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
43
src/Repository/SeriesRepository.php
Normal file
43
src/Repository/SeriesRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Series;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Series>
|
||||
*/
|
||||
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()
|
||||
// ;
|
||||
// }
|
||||
}
|
43
src/Repository/SpeakerRepository.php
Normal file
43
src/Repository/SpeakerRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Speaker;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Speaker>
|
||||
*/
|
||||
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()
|
||||
// ;
|
||||
// }
|
||||
}
|
43
src/Repository/TemplateRepository.php
Normal file
43
src/Repository/TemplateRepository.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Template;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Template>
|
||||
*/
|
||||
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()
|
||||
// ;
|
||||
// }
|
||||
}
|
60
src/Repository/UserRepository.php
Normal file
60
src/Repository/UserRepository.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<User>
|
||||
*/
|
||||
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to upgrade (rehash) the user's password automatically over time.
|
||||
*/
|
||||
public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
|
||||
}
|
||||
|
||||
$user->setPassword($newHashedPassword);
|
||||
$this->getEntityManager()->persist($user);
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return User[] Returns an array of User objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('u')
|
||||
// ->andWhere('u.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('u.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?User
|
||||
// {
|
||||
// return $this->createQueryBuilder('u')
|
||||
// ->andWhere('u.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue
Block a user