|
|
@@ -63,12 +63,36 @@ class User implements UserInterface
|
|
|
*/
|
|
|
private $description;
|
|
|
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=Message::class, mappedBy="mentions")
|
|
|
+ */
|
|
|
+ private $mentionedMessages;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\OneToMany(targetEntity=Retweets::class, mappedBy="retweeter")
|
|
|
+ */
|
|
|
+ private $retweets;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=PrivateDiscussion::class, mappedBy="participants")
|
|
|
+ */
|
|
|
+ private $privateDiscussions;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\OneToMany(targetEntity=PrivateMessage::class, mappedBy="sender", orphanRemoval=true)
|
|
|
+ */
|
|
|
+ private $privateMessages;
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->blockedUsers = new ArrayCollection();
|
|
|
$this->messages = new ArrayCollection();
|
|
|
$this->followers = new ArrayCollection();
|
|
|
$this->subscriptions = new ArrayCollection();
|
|
|
+ $this->mentionedMessages = new ArrayCollection();
|
|
|
+ $this->retweets = new ArrayCollection();
|
|
|
+ $this->privateDiscussions = new ArrayCollection();
|
|
|
+ $this->privateMessages = new ArrayCollection();
|
|
|
}
|
|
|
|
|
|
public function getId(): ?int
|
|
|
@@ -240,4 +264,115 @@ class User implements UserInterface
|
|
|
{
|
|
|
// TODO: Implement eraseCredentials() method.
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|Message[]
|
|
|
+ */
|
|
|
+ public function getMentionedMessages(): Collection
|
|
|
+ {
|
|
|
+ return $this->mentionedMessages;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addMentionedMessage(Message $mentionedMessage): self
|
|
|
+ {
|
|
|
+ if (!$this->mentionedMessages->contains($mentionedMessage)) {
|
|
|
+ $this->mentionedMessages[] = $mentionedMessage;
|
|
|
+ $mentionedMessage->addMentiotest($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeMentionedMessage(Message $mentionedMessage): self
|
|
|
+ {
|
|
|
+ if ($this->mentionedMessages->removeElement($mentionedMessage)) {
|
|
|
+ $mentionedMessage->removeMentiotest($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|Retweets[]
|
|
|
+ */
|
|
|
+ public function getRetweets(): Collection
|
|
|
+ {
|
|
|
+ return $this->retweets;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addRetweet(Retweets $retweet): self
|
|
|
+ {
|
|
|
+ if (!$this->retweets->contains($retweet)) {
|
|
|
+ $this->retweets[] = $retweet;
|
|
|
+ $retweet->addRetweeter($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeRetweet(Retweets $retweet): self
|
|
|
+ {
|
|
|
+ if ($this->retweets->removeElement($retweet)) {
|
|
|
+ $retweet->removeRetweeter($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|PrivateDiscussion[]
|
|
|
+ */
|
|
|
+ public function getPrivateDiscussions(): Collection
|
|
|
+ {
|
|
|
+ return $this->privateDiscussions;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addPrivateDiscussion(PrivateDiscussion $privateDiscussion): self
|
|
|
+ {
|
|
|
+ if (!$this->privateDiscussions->contains($privateDiscussion)) {
|
|
|
+ $this->privateDiscussions[] = $privateDiscussion;
|
|
|
+ $privateDiscussion->addParticipant($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removePrivateDiscussion(PrivateDiscussion $privateDiscussion): self
|
|
|
+ {
|
|
|
+ if ($this->privateDiscussions->removeElement($privateDiscussion)) {
|
|
|
+ $privateDiscussion->removeParticipant($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|PrivateMessage[]
|
|
|
+ */
|
|
|
+ public function getPrivateMessages(): Collection
|
|
|
+ {
|
|
|
+ return $this->privateMessages;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addPrivateMessage(PrivateMessage $privateMessage): self
|
|
|
+ {
|
|
|
+ if (!$this->privateMessages->contains($privateMessage)) {
|
|
|
+ $this->privateMessages[] = $privateMessage;
|
|
|
+ $privateMessage->setSender($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removePrivateMessage(PrivateMessage $privateMessage): self
|
|
|
+ {
|
|
|
+ if ($this->privateMessages->removeElement($privateMessage)) {
|
|
|
+ // set the owning side to null (unless already changed)
|
|
|
+ if ($privateMessage->getSender() === $this) {
|
|
|
+ $privateMessage->setSender(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
}
|