Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Gedmo\Mapping\Annotation as Gedmo;
- /**
- * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
- */
- class User implements UserInterface, \Serializable
- {
- /**
- * @ORM\Id()
- * @ORM\GeneratedValue()
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=180, unique=true)
- */
- private $username;
- /**
- * @Gedmo\Slug(fields={"username"})
- * @ORM\Column(length=255, unique=true)
- */
- private $slug;
- /**
- * @ORM\Column(type="array")
- */
- private $roles = [];
- /**
- * @ORM\Column(type="string", length=64)
- */
- private $password;
- private $plainPassword;
- private $plainPasswordConfirm;
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\Classification", mappedBy="user", orphanRemoval=true)
- */
- private $classification;
- /**
- * @var \DateTime $createdAt
- *
- * @Gedmo\Timestampable(on="create")
- * @ORM\Column(type="datetime")
- */
- private $createdAt;
- /**
- * @var \DateTime $updatedAt
- *
- * @Gedmo\Timestampable(on="update")
- * @ORM\Column(type="datetime")
- */
- private $updatedAt;
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\Comments", mappedBy="user")
- */
- private $comments;
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="user", orphanRemoval=true)
- */
- private $inboxes;
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="sender")
- */
- private $inboxSenders;
- /**
- * @ORM\OneToMany(targetEntity="App\Entity\Inbox", mappedBy="receiver")
- */
- private $inboxReceivers;
- public function __construct()
- {
- $this->classification = new ArrayCollection();
- $this->createdAt = new \Datetime();
- $this->updatedAt = new \Datetime();
- $this->comments = new ArrayCollection();
- $this->inboxes = new ArrayCollection();
- $this->inboxSenders = new ArrayCollection();
- $this->inboxReceivers = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * A visual identifier that represents this user.
- *
- * @see UserInterface
- */
- public function getUsername(): string
- {
- return (string) $this->username;
- }
- public function setUsername(string $username): self
- {
- $this->username = $username;
- return $this;
- }
- public function getSlug(): ?string
- {
- return $this->slug;
- }
- public function setSlug(string $slug): self
- {
- $this->slug = $slug;
- return $this;
- }
- public function setRoles(array $roles): self
- {
- $this->roles = $roles;
- return $this;
- }
- public function getRoles(): array
- {
- $roles = $this->roles;
- // $roles[] = 'ROLE_MEMBER';
- return array_unique($roles);
- }
- public function getPassword(): ?string
- {
- return $this->password;
- }
- public function setPassword($password): self
- {
- $this->password = $password;
- return $this;
- }
- public function getPlainPassword(): ?string
- {
- return $this->plainPassword;
- }
- public function setPlainPassword($plainPassword): self
- {
- $this->plainPassword = $plainPassword;
- return $this;
- }
- public function getPlainPasswordConfirm(): ?string
- {
- return $this->plainPasswordConfirm;
- }
- public function setPlainPasswordConfirm($plainPasswordConfirm): self
- {
- $this->plainPasswordConfirm = $plainPasswordConfirm;
- return $this;
- }
- /**
- * @see UserInterface
- */
- public function getSalt()
- {
- // not needed when using the "bcrypt" algorithm in security.yaml
- }
- /**
- * @see UserInterface
- */
- public function eraseCredentials()
- {
- // If you store any temporary, sensitive data on the user, clear it here
- // $this->plainPassword = null;
- }
- /** @see \Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->username,
- $this->password,
- ));
- }
- public function unserialize($serialized)
- {
- list(
- $this->id,
- $this->username,
- $this->password,
- ) = unserialize($serialized);
- }
- public function __toString()
- {
- return (string) $this->username;
- }
- /**
- * @return Collection|Classification[]
- */
- public function getClassification(): Collection
- {
- return $this->classification;
- }
- public function addClassification(Classification $classification): self
- {
- if (!$this->classification->contains($classification)) {
- $this->classification[] = $classification;
- $classification->setUser($this);
- }
- return $this;
- }
- public function removeClassification(Classification $classification): self
- {
- if ($this->classification->contains($classification)) {
- $this->classification->removeElement($classification);
- // set the owning side to null (unless already changed)
- if ($classification->getUser() === $this) {
- $classification->setUser(null);
- }
- }
- return $this;
- }
- public function getCreatedAt(): ?\DateTimeInterface
- {
- return $this->createdAt;
- }
- public function setCreatedAt(\DateTimeInterface $createdAt): self
- {
- $this->createdAt = $createdAt;
- return $this;
- }
- public function getUpdatedAt(): ?\DateTimeInterface
- {
- return $this->updatedAt;
- }
- public function setUpdatedAt(\DateTimeInterface $updatedAt): self
- {
- $this->updatedAt = $updatedAt;
- return $this;
- }
- /**
- * @return Collection|Comments[]
- */
- public function getComments(): Collection
- {
- return $this->comments;
- }
- public function addComment(Comments $comment): self
- {
- if (!$this->comments->contains($comment)) {
- $this->comments[] = $comment;
- $comment->setUser($this);
- }
- return $this;
- }
- public function removeComment(Comments $comment): self
- {
- if ($this->comments->contains($comment)) {
- $this->comments->removeElement($comment);
- // set the owning side to null (unless already changed)
- if ($comment->getUser() === $this) {
- $comment->setUser(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection|Inbox[]
- */
- public function getInboxes(): Collection
- {
- return $this->inboxes;
- }
- public function addInbox(Inbox $inbox): self
- {
- if (!$this->inboxes->contains($inbox)) {
- $this->inboxes[] = $inbox;
- $inbox->setUser($this);
- }
- return $this;
- }
- public function removeInbox(Inbox $inbox): self
- {
- if ($this->inboxes->contains($inbox)) {
- $this->inboxes->removeElement($inbox);
- // set the owning side to null (unless already changed)
- if ($inbox->getUser() === $this) {
- $inbox->setUser(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection|Inbox[]
- */
- public function getInboxSenders(): Collection
- {
- return $this->inboxSenders;
- }
- public function addInboxSender(Inbox $inboxSender): self
- {
- if (!$this->inboxSenders->contains($inboxSender)) {
- $this->inboxSenders[] = $inboxSender;
- $inboxSender->setSender($this);
- }
- return $this;
- }
- public function removeInboxSender(Inbox $inboxSender): self
- {
- if ($this->inboxSenders->contains($inboxSender)) {
- $this->inboxSenders->removeElement($inboxSender);
- // set the owning side to null (unless already changed)
- if ($inboxSender->getSender() === $this) {
- $inboxSender->setSender(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection|Inbox[]
- */
- public function getInboxReceivers(): Collection
- {
- return $this->inboxReceivers;
- }
- public function addInboxReceiver(Inbox $inboxReceiver): self
- {
- if (!$this->inboxReceivers->contains($inboxReceiver)) {
- $this->inboxReceivers[] = $inboxReceiver;
- $inboxReceiver->setReceiver($this);
- }
- return $this;
- }
- public function removeInboxReceiver(Inbox $inboxReceiver): self
- {
- if ($this->inboxReceivers->contains($inboxReceiver)) {
- $this->inboxReceivers->removeElement($inboxReceiver);
- // set the owning side to null (unless already changed)
- if ($inboxReceiver->getReceiver() === $this) {
- $inboxReceiver->setReceiver(null);
- }
- }
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement