<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`user`")
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"message","post","post-group-session","conversation"})
*/
private $id;
/**
* @ORM\Column(type="string", length=181)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $idCustomer;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $idUserProfil;
/**
* @ORM\Column(type="string", length=45, nullable=true)
*/
private $job;
/**
* @ORM\Column(type="string", length=45, nullable=true)
*/
private $service;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $schoolDegree1;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $schoolDegree2;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $userName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"message","post","post-group-session","conversation"})
*/
private $lastName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"message","post","post-group-session","conversation"})
*/
private $firstName;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isActive;
/**
* @ORM\OneToMany(targetEntity=ParticipantConversation::class, mappedBy="user")
*/
private $participants;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="user")
*/
private $messages;
/**
* @ORM\OneToMany(targetEntity=ForumTopic::class, mappedBy="user")
*/
private $forumTopics;
/**
* @ORM\OneToMany(targetEntity=ForumPost::class, mappedBy="user")
*/
private $forumPosts;
/**
* @ORM\ManyToMany(targetEntity=LMSFormation::class, mappedBy="user")
*/
private $lMSFormations;
/**
* @ORM\OneToMany(targetEntity=LMSAnswerUser::class, mappedBy="user")
*/
private $lMSAnswerUsers;
/**
* @ORM\ManyToMany(targetEntity=GroupSession::class, mappedBy="user")
*/
private $groupSessions;
/**
* @ORM\OneToMany(targetEntity=GroupSessionMessage::class, mappedBy="user")
*/
private $groupSessionMessages;
/**
* @ORM\ManyToMany(targetEntity=LMSContent::class, mappedBy="userProgression")
*/
private $lMSContents;
/**
* @ORM\OneToMany(targetEntity=LMSAnswerSurveyUser::class, mappedBy="user")
*/
private $lMSAnswerSurveyUsers;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="user")
*/
private $notifications;
/**
* onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement.
*/
private $typeCourseSession;
/**
* @ORM\ManyToMany(targetEntity=LMSModule::class, mappedBy="user")
*/
private $lMSModules;
/**
* @ORM\OneToMany(targetEntity=LMSFreeAnswerSurvey::class, mappedBy="user")
*/
private $lMSFreeAnswerSurveys;
/**
* @ORM\ManyToMany(targetEntity=LMSSequence::class, inversedBy="users")
*/
private $LMSSequences;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isProfessional;
public function __construct()
{
$this->participants = new ArrayCollection();
$this->messages = new ArrayCollection();
$this->forumTopics = new ArrayCollection();
$this->forumPosts = new ArrayCollection();
$this->lMSFormations = new ArrayCollection();
$this->lMSAnswerUsers = new ArrayCollection();
$this->groupSessions = new ArrayCollection();
$this->groupSessionMessages = new ArrayCollection();
$this->lMSContents = new ArrayCollection();
$this->lMSAnswerSurveyUsers = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->typeCourseSession = 0;
$this->lMSModules = new ArrayCollection();
$this->lMSFreeAnswerSurveys = new ArrayCollection();
$this->LMSSequences = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->userName;
}
/**
* @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;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function getIdCustomer(): ?int
{
return $this->idCustomer;
}
public function setIdCustomer(int $idCustomer): self
{
$this->idCustomer = $idCustomer;
return $this;
}
public function getIdUserProfil(): ?int
{
return $this->idUserProfil;
}
public function setIdUserProfil(int $idUserProfil): self
{
$this->idUserProfil = $idUserProfil;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function getService(): ?string
{
return $this->service;
}
public function setService(?string $service): self
{
$this->service = $service;
return $this;
}
public function getSchoolDegree1(): ?string
{
return $this->schoolDegree1;
}
public function setSchoolDegree1(?string $schoolDegree1): self
{
$this->schoolDegree1 = $schoolDegree1;
return $this;
}
public function getSchoolDegree2(): ?string
{
return $this->schoolDegree2;
}
public function setSchoolDegree2(?string $schoolDegree2): self
{
$this->schoolDegree2 = $schoolDegree2;
return $this;
}
public function setUserName(?string $userName): self
{
$this->userName = $userName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(?bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* @return Collection<int, ParticipantConversation>
*/
public function getParticipants(): Collection
{
return $this->participants;
}
public function addParticipant(ParticipantConversation $participant): self
{
if (!$this->participants->contains($participant)) {
$this->participants[] = $participant;
$participant->setUser($this);
}
return $this;
}
public function removeParticipant(ParticipantConversation $participant): self
{
if ($this->participants->removeElement($participant)) {
// set the owning side to null (unless already changed)
if ($participant->getUser() === $this) {
$participant->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Message>
*/
public function getMessages(): Collection
{
return $this->messages;
}
public function addMessage(Message $message): self
{
if (!$this->messages->contains($message)) {
$this->messages[] = $message;
$message->setMessages($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->getMessages() === $this) {
$message->setMessages(null);
}
}
return $this;
}
/**
* @return Collection<int, ForumTopic>
*/
public function getForumTopics(): Collection
{
return $this->forumTopics;
}
public function addForumTopic(ForumTopic $forumTopic): self
{
if (!$this->forumTopics->contains($forumTopic)) {
$this->forumTopics[] = $forumTopic;
$forumTopic->setUser($this);
}
return $this;
}
public function removeForumTopic(ForumTopic $forumTopic): self
{
if ($this->forumTopics->removeElement($forumTopic)) {
// set the owning side to null (unless already changed)
if ($forumTopic->getUser() === $this) {
$forumTopic->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, ForumPost>
*/
public function getForumPosts(): Collection
{
return $this->forumPosts;
}
public function addForumPost(ForumPost $forumPost): self
{
if (!$this->forumPosts->contains($forumPost)) {
$this->forumPosts[] = $forumPost;
$forumPost->setUser($this);
}
return $this;
}
public function removeForumPost(ForumPost $forumPost): self
{
if ($this->forumPosts->removeElement($forumPost)) {
// set the owning side to null (unless already changed)
if ($forumPost->getUser() === $this) {
$forumPost->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LMSFormation>
*/
public function getLMSFormations(): Collection
{
return $this->lMSFormations;
}
public function addLMSFormation(LMSFormation $lMSFormation): self
{
if (!$this->lMSFormations->contains($lMSFormation)) {
$this->lMSFormations[] = $lMSFormation;
$lMSFormation->addUser($this);
}
return $this;
}
public function removeLMSFormation(LMSFormation $lMSFormation): self
{
if ($this->lMSFormations->removeElement($lMSFormation)) {
$lMSFormation->removeUser($this);
}
return $this;
}
/**
* @return Collection<int, LMSAnswerUser>
*/
public function getLMSAnswerUsers(): Collection
{
return $this->lMSAnswerUsers;
}
public function addLMSAnswerUser(LMSAnswerUser $lMSAnswerUser): self
{
if (!$this->lMSAnswerUsers->contains($lMSAnswerUser)) {
$this->lMSAnswerUsers[] = $lMSAnswerUser;
$lMSAnswerUser->setUser($this);
}
return $this;
}
public function removeLMSAnswerUser(LMSAnswerUser $lMSAnswerUser): self
{
if ($this->lMSAnswerUsers->removeElement($lMSAnswerUser)) {
// set the owning side to null (unless already changed)
if ($lMSAnswerUser->getUser() === $this) {
$lMSAnswerUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, GroupSession>
*/
public function getGroupSessions(): Collection
{
return $this->groupSessions;
}
public function addGroupSession(GroupSession $groupSession): self
{
if (!$this->groupSessions->contains($groupSession)) {
$this->groupSessions[] = $groupSession;
$groupSession->addUser($this);
}
return $this;
}
public function removeGroupSession(GroupSession $groupSession): self
{
if ($this->groupSessions->removeElement($groupSession)) {
$groupSession->removeUser($this);
}
return $this;
}
/**
* @return Collection<int, GroupSessionMessage>
*/
public function getGroupSessionMessages(): Collection
{
return $this->groupSessionMessages;
}
public function addGroupSessionMessage(GroupSessionMessage $groupSessionMessage): self
{
if (!$this->groupSessionMessages->contains($groupSessionMessage)) {
$this->groupSessionMessages[] = $groupSessionMessage;
$groupSessionMessage->setUser($this);
}
return $this;
}
public function removeGroupSessionMessage(GroupSessionMessage $groupSessionMessage): self
{
if ($this->groupSessionMessages->removeElement($groupSessionMessage)) {
// set the owning side to null (unless already changed)
if ($groupSessionMessage->getUser() === $this) {
$groupSessionMessage->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LMSContent>
*/
public function getLMSContents(): Collection
{
return $this->lMSContents;
}
public function addLMSContent(LMSContent $lMSContent): self
{
if (!$this->lMSContents->contains($lMSContent)) {
$this->lMSContents[] = $lMSContent;
$lMSContent->addUserProgression($this);
}
return $this;
}
public function removeLMSContent(LMSContent $lMSContent): self
{
if ($this->lMSContents->removeElement($lMSContent)) {
$lMSContent->removeUserProgression($this);
}
return $this;
}
/**
* @return Collection<int, LMSAnswerSurveyUser>
*/
public function getLMSAnswerSurveyUsers(): Collection
{
return $this->lMSAnswerSurveyUsers;
}
public function addLMSAnswerSurveyUser(LMSAnswerSurveyUser $lMSAnswerSurveyUser): self
{
if (!$this->lMSAnswerSurveyUsers->contains($lMSAnswerSurveyUser)) {
$this->lMSAnswerSurveyUsers[] = $lMSAnswerSurveyUser;
$lMSAnswerSurveyUser->setUser($this);
}
return $this;
}
public function removeLMSAnswerSurveyUser(LMSAnswerSurveyUser $lMSAnswerSurveyUser): self
{
if ($this->lMSAnswerSurveyUsers->removeElement($lMSAnswerSurveyUser)) {
// set the owning side to null (unless already changed)
if ($lMSAnswerSurveyUser->getUser() === $this) {
$lMSAnswerSurveyUser->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setUser($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getUser() === $this) {
$notification->setUser(null);
}
}
return $this;
}
/**
* Get onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement.
*/
public function getTypeCourseSession()
{
return $this->typeCourseSession;
}
/**
* Set onSite / remote : définit le type de formation lors de l'inscription de l'étudiant et du paiemement.
*
* @return self
*/
public function setTypeCourseSession($typeCourseSession)
{
$this->typeCourseSession = $typeCourseSession;
return $this;
}
/**
* @return Collection<int, LMSModule>
*/
public function getLMSModules(): Collection
{
return $this->lMSModules;
}
public function addLMSModule(LMSModule $lMSModule): self
{
if (!$this->lMSModules->contains($lMSModule)) {
$this->lMSModules[] = $lMSModule;
$lMSModule->addUser($this);
}
return $this;
}
public function removeLMSModule(LMSModule $lMSModule): self
{
if ($this->lMSModules->removeElement($lMSModule)) {
$lMSModule->removeUser($this);
}
return $this;
}
/**
* @return Collection<int, LMSFreeAnswerSurvey>
*/
public function getLMSFreeAnswerSurveys(): Collection
{
return $this->lMSFreeAnswerSurveys;
}
public function addLMSFreeAnswerSurvey(LMSFreeAnswerSurvey $lMSFreeAnswerSurvey): self
{
if (!$this->lMSFreeAnswerSurveys->contains($lMSFreeAnswerSurvey)) {
$this->lMSFreeAnswerSurveys[] = $lMSFreeAnswerSurvey;
$lMSFreeAnswerSurvey->setUser($this);
}
return $this;
}
public function removeLMSFreeAnswerSurvey(LMSFreeAnswerSurvey $lMSFreeAnswerSurvey): self
{
if ($this->lMSFreeAnswerSurveys->removeElement($lMSFreeAnswerSurvey)) {
// set the owning side to null (unless already changed)
if ($lMSFreeAnswerSurvey->getUser() === $this) {
$lMSFreeAnswerSurvey->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, LMSSequence>
*/
public function getLMSSequences(): Collection
{
return $this->LMSSequences;
}
public function addLMSSequence(LMSSequence $lMSSequence): self
{
if (!$this->LMSSequences->contains($lMSSequence)) {
$this->LMSSequences[] = $lMSSequence;
}
return $this;
}
public function removeLMSSequence(LMSSequence $lMSSequence): self
{
$this->LMSSequences->removeElement($lMSSequence);
return $this;
}
public function getIsProfessional(): ?bool
{
return $this->isProfessional;
}
public function setIsProfessional(?bool $isProfessional): self
{
$this->isProfessional = $isProfessional;
return $this;
}
}