|
|
@ -5,117 +5,211 @@ namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\Common\Collections\Collection;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
|
|
|
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class User {
|
|
|
|
class User implements UserInterface
|
|
|
|
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var int The internal ID of user
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\Id()
|
|
|
|
* @ORM\Id()
|
|
|
|
* @ORM\GeneratedValue()
|
|
|
|
* @ORM\GeneratedValue()
|
|
|
|
* @ORM\Column(type="integer")
|
|
|
|
* @ORM\Column(type="integer")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $id;
|
|
|
|
private int $id;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=70)
|
|
|
|
* @var string The user email
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @ORM\Column(type="string", length=180, unique=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $email;
|
|
|
|
private string $email;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
* @var array The list of user's roles
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @ORM\Column(type="json")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $pass;
|
|
|
|
private array $roles = [];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var string The hashed password
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @ORM\Column(type="string")
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private string $password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var string The user name
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
* @ORM\Column(type="string", length=255)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $name;
|
|
|
|
private string $name;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var string|null The user first name
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $fistname;
|
|
|
|
private ?string $fist_name;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var int The user gender
|
|
|
|
|
|
|
|
* 0 = no gender
|
|
|
|
|
|
|
|
* 1 = male
|
|
|
|
|
|
|
|
* 2 = femalle
|
|
|
|
|
|
|
|
* 3 = genderqueer
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\Column(type="smallint")
|
|
|
|
* @ORM\Column(type="smallint")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $gender;
|
|
|
|
private int $gender;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var string|null The user avatar relative path
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
* @ORM\Column(type="string", length=255, nullable=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $avatar;
|
|
|
|
private ?string $avatar;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var Language The user language
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
|
|
|
|
* @ORM\ManyToOne(targetEntity="App\Entity\Language")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $language;
|
|
|
|
private Language $language;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection The user {@see User friends}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\User")
|
|
|
|
* @ORM\ManyToMany(targetEntity="App\Entity\User")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $friends;
|
|
|
|
private ArrayCollection $friends;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection The user {@see ConfigNotification configured notifications}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\ConfigNotification", mappedBy="user", orphanRemoval=true)
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\ConfigNotification", mappedBy="user", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $configNotifications;
|
|
|
|
private ArrayCollection $configNotifications;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection Thue user {@see UserNotification notifications}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\UserNotification", mappedBy="user", orphanRemoval=true)
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\UserNotification", mappedBy="user", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $notifications;
|
|
|
|
private ArrayCollection $notifications;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection The user owned {@see Wish wishes}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Wish", mappedBy="owner")
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Wish", mappedBy="owner")
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $ownedWishes;
|
|
|
|
private ArrayCollection $ownedWishes;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection The user {@see Participant participations}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Participant", mappedBy="user", orphanRemoval=true)
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Participant", mappedBy="user", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $participations;
|
|
|
|
private ArrayCollection $participations;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @var ArrayCollection The user {@see Comment comments}
|
|
|
|
|
|
|
|
*
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="user", orphanRemoval=true)
|
|
|
|
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="user", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private $comments;
|
|
|
|
private ArrayCollection $comments;
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct () {
|
|
|
|
public function __construct () {
|
|
|
|
$this->friends = new ArrayCollection();
|
|
|
|
$this->friends = new ArrayCollection();
|
|
|
|
$this->configNotifications = new ArrayCollection();
|
|
|
|
$this->configNotifications = new ArrayCollection();
|
|
|
|
$this->notifications = new ArrayCollection();
|
|
|
|
$this->notifications = new ArrayCollection();
|
|
|
|
$this->memberOfGroups = new ArrayCollection();
|
|
|
|
|
|
|
|
$this->ownedWishes = new ArrayCollection();
|
|
|
|
$this->ownedWishes = new ArrayCollection();
|
|
|
|
$this->participations = new ArrayCollection();
|
|
|
|
$this->participations = new ArrayCollection();
|
|
|
|
$this->comments = new ArrayCollection();
|
|
|
|
$this->comments = new ArrayCollection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getId (): ?int {
|
|
|
|
public function getId(): ?int
|
|
|
|
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getEmail (): ?string {
|
|
|
|
public function getEmail(): ?string
|
|
|
|
|
|
|
|
{
|
|
|
|
return $this->email;
|
|
|
|
return $this->email;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setEmail (string $email): self {
|
|
|
|
public function setEmail(string $email): self
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->email = $email;
|
|
|
|
$this->email = $email;
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getPass (): ?string {
|
|
|
|
/**
|
|
|
|
return $this->pass;
|
|
|
|
* A visual identifier that represents this user.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @see UserInterface
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getUsername(): string
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (string) $this->email;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setPass (string $pass): self {
|
|
|
|
/**
|
|
|
|
$this->pass = $pass;
|
|
|
|
* @see UserInterface
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getRoles(): array
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$roles = $this->roles;
|
|
|
|
|
|
|
|
// guarantee every user at least has ROLE_USER
|
|
|
|
|
|
|
|
$roles[] = 'ROLE_USER';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return array_unique($roles);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setRoles(array $roles): self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->roles = $roles;
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @see UserInterface
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getPassword(): string
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return (string) $this->password;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function setPassword(string $password): self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->password = $password;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getName (): ?string {
|
|
|
|
public function getName (): ?string {
|
|
|
|
return $this->name;
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,11 +221,11 @@ class User {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getFistname (): ?string {
|
|
|
|
public function getFistname (): ?string {
|
|
|
|
return $this->fistname;
|
|
|
|
return $this->fist_name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function setFistname (?string $fistname): self {
|
|
|
|
public function setFistname (?string $fist_name): self {
|
|
|
|
$this->fistname = $fistname;
|
|
|
|
$this->fist_name = $fist_name;
|
|
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|