|
|
@@ -0,0 +1,227 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Entity;
|
|
|
+
|
|
|
+use App\Repository\UserRepository;
|
|
|
+use Doctrine\Common\Collections\ArrayCollection;
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ORM\Entity(repositoryClass=UserRepository::class)
|
|
|
+ */
|
|
|
+class User
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * @ORM\Id
|
|
|
+ * @ORM\GeneratedValue
|
|
|
+ * @ORM\Column(type="integer")
|
|
|
+ */
|
|
|
+ private $id;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255)
|
|
|
+ */
|
|
|
+ private $username;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="boolean")
|
|
|
+ */
|
|
|
+ private $isPrivate;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255)
|
|
|
+ */
|
|
|
+ private $password;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=User::class)
|
|
|
+ * @ORM\JoinTable(name="user_blockeduser")
|
|
|
+ */
|
|
|
+ private $blockedUsers;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\OneToMany(targetEntity=Message::class, mappedBy="sender", orphanRemoval=true)
|
|
|
+ */
|
|
|
+ private $messages;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=User::class)
|
|
|
+ * @ORM\JoinTable(name="user_follower")
|
|
|
+ */
|
|
|
+ private $followers;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\ManyToMany(targetEntity=User::class)
|
|
|
+ * @ORM\JoinTable(name="user_subscription")
|
|
|
+ */
|
|
|
+ private $subscriptions;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @ORM\Column(type="string", length=255, nullable=true)
|
|
|
+ */
|
|
|
+ private $description;
|
|
|
+
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ $this->blockedUsers = new ArrayCollection();
|
|
|
+ $this->messages = new ArrayCollection();
|
|
|
+ $this->followers = new ArrayCollection();
|
|
|
+ $this->subscriptions = new ArrayCollection();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getId(): ?int
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getUsername(): ?string
|
|
|
+ {
|
|
|
+ return $this->username;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setUsername(string $username): self
|
|
|
+ {
|
|
|
+ $this->username = $username;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getIsPrivate(): ?bool
|
|
|
+ {
|
|
|
+ return $this->isPrivate;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setIsPrivate(bool $isPrivate): self
|
|
|
+ {
|
|
|
+ $this->isPrivate = $isPrivate;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getPassword(): ?string
|
|
|
+ {
|
|
|
+ return $this->password;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setPassword(string $password): self
|
|
|
+ {
|
|
|
+ $this->password = $password;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|self[]
|
|
|
+ */
|
|
|
+ public function getBlockedUsers(): Collection
|
|
|
+ {
|
|
|
+ return $this->blockedUsers;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addBlockedUser(self $blockedUser): self
|
|
|
+ {
|
|
|
+ if (!$this->blockedUsers->contains($blockedUser)) {
|
|
|
+ $this->blockedUsers[] = $blockedUser;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeBlockedUser(self $blockedUser): self
|
|
|
+ {
|
|
|
+ $this->blockedUsers->removeElement($blockedUser);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|Message[]
|
|
|
+ */
|
|
|
+ public function getMessages(): Collection
|
|
|
+ {
|
|
|
+ return $this->messages;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addMessage(Message $message): self
|
|
|
+ {
|
|
|
+ if (!$this->messages->contains($message)) {
|
|
|
+ $this->messages[] = $message;
|
|
|
+ $message->setSender($this);
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeMessage(Message $message): self
|
|
|
+ {
|
|
|
+ if ($this->messages->removeElement($message)) {
|
|
|
+ // set the owning side to null (unless already changed)
|
|
|
+ if ($message->getSender() === $this) {
|
|
|
+ $message->setSender(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|self[]
|
|
|
+ */
|
|
|
+ public function getFollowers(): Collection
|
|
|
+ {
|
|
|
+ return $this->followers;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addFollower(self $follower): self
|
|
|
+ {
|
|
|
+ if (!$this->followers->contains($follower)) {
|
|
|
+ $this->followers[] = $follower;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeFollower(self $follower): self
|
|
|
+ {
|
|
|
+ $this->followers->removeElement($follower);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Collection|self[]
|
|
|
+ */
|
|
|
+ public function getSubscriptions(): Collection
|
|
|
+ {
|
|
|
+ return $this->subscriptions;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function addSubscription(self $subscription): self
|
|
|
+ {
|
|
|
+ if (!$this->subscriptions->contains($subscription)) {
|
|
|
+ $this->subscriptions[] = $subscription;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function removeSubscription(self $subscription): self
|
|
|
+ {
|
|
|
+ $this->subscriptions->removeElement($subscription);
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDescription(): ?string
|
|
|
+ {
|
|
|
+ return $this->description;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setDescription(?string $description): self
|
|
|
+ {
|
|
|
+ $this->description = $description;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
+}
|