|
@@ -42,6 +42,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
#[ORM\OneToMany(targetEntity: Article::class, mappedBy: 'author', orphanRemoval: true)]
|
|
|
private Collection $articles;
|
|
|
|
|
|
+ #[ORM\Column(length: 64, nullable: true)]
|
|
|
+ private ?string $pseudo = null;
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
$this->articles = new ArrayCollection();
|
|
@@ -49,7 +52,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
|
|
public function __toString(): string
|
|
|
{
|
|
|
- return $this->getUserIdentifier();
|
|
|
+ return $this->getPseudo() ?? $this->getUserIdentifier();
|
|
|
}
|
|
|
|
|
|
public function getId(): ?int
|
|
@@ -88,7 +91,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
{
|
|
|
$roles = $this->roles;
|
|
|
// guarantee every user at least has ROLE_USER
|
|
|
- $roles[] = 'ROLE_USER';
|
|
|
+ $roles[] = 'ROLE_AUTHOR';
|
|
|
|
|
|
return array_unique($roles);
|
|
|
}
|
|
@@ -168,4 +171,16 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
+
|
|
|
+ public function getPseudo(): ?string
|
|
|
+ {
|
|
|
+ return $this->pseudo;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function setPseudo(?string $pseudo): static
|
|
|
+ {
|
|
|
+ $this->pseudo = $pseudo;
|
|
|
+
|
|
|
+ return $this;
|
|
|
+ }
|
|
|
}
|