This commit is contained in:
2024-06-23 22:41:33 -04:00
parent 752b2a291e
commit d24c304c97
6 changed files with 303 additions and 10 deletions

View File

@ -68,12 +68,22 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, JsonSer
#[ORM\OneToMany(targetEntity: Note::class, mappedBy: 'user')]
private Collection $notes;
/**
* @var Collection<int, NoteShares>
*/
#[ORM\OneToMany(targetEntity: NoteShares::class, mappedBy: 'ownerId', orphanRemoval: true)]
private Collection $noteShares;
#[ORM\Column(nullable: true)]
private ?array $metaData = null;
public function __construct()
{
$this->series = new ArrayCollection();
$this->speakers = new ArrayCollection();
$this->templates = new ArrayCollection();
$this->notes = new ArrayCollection();
$this->noteShares = new ArrayCollection();
}
public function getId(): ?Uuid
@ -81,6 +91,11 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, JsonSer
return $this->id;
}
public function getHexId(): string
{
return $this->id->toHex();
}
public function setId(?Uuid $id): static
{
$this->id = $id;
@ -303,4 +318,46 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface, JsonSer
'name' => $this->name,
];
}
/**
* @return Collection<int, NoteShares>
*/
public function getNoteShares(): Collection
{
return $this->noteShares;
}
public function addNoteShare(NoteShares $noteShare): static
{
if (!$this->noteShares->contains($noteShare)) {
$this->noteShares->add($noteShare);
$noteShare->setOwner($this);
}
return $this;
}
public function removeNoteShare(NoteShares $noteShare): static
{
if ($this->noteShares->removeElement($noteShare)) {
// set the owning side to null (unless already changed)
if ($noteShare->getOwner() === $this) {
$noteShare->setOwner(null);
}
}
return $this;
}
public function getMetaData(): ?array
{
return $this->metaData;
}
public function setMetaData(?array $metaData): static
{
$this->metaData = $metaData;
return $this;
}
}