src/Entity/Account/User.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Account;
  3. use App\Entity\Channel\Channel;
  4. use App\Entity\Channel\Group;
  5. use App\Entity\Channel\Service;
  6. use App\Entity\ChannelUserData\ChannelUserData;
  7. use App\Entity\Chat\ChatNotification;
  8. use App\Entity\Chat\Conversation;
  9. use App\Entity\Chat\ConversationUser;
  10. use App\Repository\Account\UserRepository;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Nellapp\Bundle\SDKBundle\Auth\Entity\Token;
  15. use Nellapp\Bundle\SDKBundle\Auth\Entity\UserInterface;
  16. use Nellapp\Bundle\SDKBundle\Auth\Entity\UserMethodTrait;
  17. use Symfony\Component\Serializer\Annotation as Serial;
  18. #[
  19.     ORM\Entity(repositoryClassUserRepository::class),
  20.     ORM\Index(columns: ['email'], flags: ['fulltext']),
  21.     ORM\Index(columns: ['first_name''last_name'], flags: ['fulltext']),
  22.     ORM\Table(name'account_users'),
  23. ]
  24. class User implements UserInterface
  25. {
  26.     use UserMethodTrait;
  27.     #[ORM\IdORM\Column(type'string')]
  28.     #[Serial\Groups(['Message''WS_MESSAGE''Conversation''GlobalJSVariable''PostMessage''PostMessageReaction''PostCoordinators''ChatNotification''Api'])]
  29.     private ?string $id null;
  30.     #[ORM\Column(type'string'length180uniquetrue)]
  31.     #[Serial\Groups(['Admin_User''Api'])]
  32.     private ?string $email null;
  33.     /**
  34.      * @var string[]
  35.      */
  36.     #[ORM\Column(type'json')]
  37.     private array $roles = [];
  38.     #[ORM\Column(type'string'nullabletrue)]
  39.     #[Serial\Groups(['Message''WS_MESSAGE''Conversation''GlobalJSVariable''ChatNotification''Api'])]
  40.     private ?string $firstName null;
  41.     #[ORM\Column(type'string'nullabletrue)]
  42.     #[Serial\Groups(['Message''WS_MESSAGE''Conversation''GlobalJSVariable''ChatNotification''Api'])]
  43.     private ?string $lastName null;
  44.     #[ORM\Column(type'text'nullabletrue)]
  45.     private ?string $description null;
  46.     #[ORM\Column(type'boolean'nullabletrue)]
  47.     private ?bool $avatar null;
  48.     #[ORM\Embedded(class: Token::class)]
  49.     private ?Token $token null;
  50.     #[ORM\Column(type'text'nullabletrue)]
  51.     #[Serial\Groups(['Message''WS_MESSAGE''Conversation''GlobalJSVariable''ChatNotification''Api'])]
  52.     private ?string $avatarPath null;
  53.     #[ORM\Column(type'datetime'nullabletrue)]
  54.     private ?\DateTime $signingLimitDate null;
  55.     #[ORM\Column(type'boolean'nullablefalseoptions: ['default' => false])]
  56.     private ?bool $hasSeenIntro false;
  57.     #[ORM\ManyToMany(targetEntityService::class, mappedBy'users')]
  58.     private Collection $services;
  59.     #[ORM\OneToMany(mappedBy'user'targetEntityConversationUser::class, cascade: ['persist''remove'], orphanRemovaltrue)]
  60.     private Collection $conversationUsers;
  61.     #[ORM\ManyToMany(targetEntityGroup::class, mappedBy'users'fetch'EXTRA_LAZY')]
  62.     private ?Collection $groups;
  63.     #[ORM\OneToMany(mappedBy'user'targetEntityChannelUserData::class)]
  64.     private ?Collection $channelUserDatas;
  65.     #[ORM\Column(type'string'nullabletrue)]
  66.     #[Serial\Groups(['Message''Conversation''GlobalJSVariable'])]
  67.     private ?string $hashTag null;
  68.     #[ORM\OneToMany(mappedBy'user'targetEntityChatNotification::class)]
  69.     private ?Collection $chatNotifications;
  70.     #[ORM\ManyToOne(targetEntityChannel::class, fetch'LAZY')]
  71.     private ?Channel $lastSelectedChannel null;
  72.     public function __construct()
  73.     {
  74.         $this->services = new ArrayCollection();
  75.         $this->conversationUsers = new ArrayCollection();
  76.         $this->channelUserDatas = new ArrayCollection();
  77.         $this->chatNotifications = new ArrayCollection();
  78.     }
  79.     #[Serial\Groups(['Message''WS_MESSAGE''Conversation''GlobalJSVariable''ChatNotification''Api'])]
  80.     public function getUserName(): string
  81.     {
  82.         return $this;
  83.     }
  84.     public function getConversationUserByConversation(Conversation $conversation): ?ConversationUser
  85.     {
  86.         $conversationUser $this->getConversationUsers()->filter(function (ConversationUser $conversationUser) use ($conversation) {
  87.             return $conversationUser->getConversation()->getId() === $conversation->getId();
  88.         })->first();
  89.         return $conversationUser !== false $conversationUser null;
  90.     }
  91.     public function getGroups(): Collection
  92.     {
  93.         return $this->groups ?? $this->groups = new ArrayCollection();
  94.     }
  95.     public function addGroup(Group $group): self
  96.     {
  97.         if (!$this->getGroups()->contains($group)) {
  98.             $this->getGroups()->add($group);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeGroup(Group $group): self
  103.     {
  104.         if ($this->getGroups()->contains($group)) {
  105.             $this->getGroups()->removeElement($group);
  106.         }
  107.         return $this;
  108.     }
  109.     public function getSigningLimitDate(): ?\DateTime
  110.     {
  111.         return $this->signingLimitDate;
  112.     }
  113.     public function setSigningLimitDate(?\DateTime $signingLimitDate): static
  114.     {
  115.         $this->signingLimitDate $signingLimitDate;
  116.         return $this;
  117.     }
  118.     public function getHasSeenIntro(): ?bool
  119.     {
  120.         return $this->hasSeenIntro;
  121.     }
  122.     public function setHasSeenIntro(bool $hasSeenIntro): self
  123.     {
  124.         $this->hasSeenIntro $hasSeenIntro;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<int, Service>
  129.      */
  130.     public function getServices(): Collection
  131.     {
  132.         return $this->services;
  133.     }
  134.     public function addService(Service $service): self
  135.     {
  136.         if (!$this->services->contains($service)) {
  137.             $this->services[] = $service;
  138.             $service->addUser($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeService(Service $service): self
  143.     {
  144.         if ($this->services->removeElement($service)) {
  145.             $service->removeUser($this);
  146.         }
  147.         return $this;
  148.     }
  149.     /**
  150.      * @return Collection<int, ConversationUser>
  151.      */
  152.     public function getConversationUsers(): Collection
  153.     {
  154.         return $this->conversationUsers ?? $this->conversationUsers = new ArrayCollection();
  155.     }
  156.     public function addConversationUser(ConversationUser $conversationUser): self
  157.     {
  158.         if (!$this->getConversationUsers()->contains($conversationUser)) {
  159.             $this->conversationUsers[] = $conversationUser;
  160.             $conversationUser->setUser($this);
  161.         }
  162.         return $this;
  163.     }
  164.     public function removeConversationUser(ConversationUser $conversationUser): self
  165.     {
  166.         if ($this->conversationUsers->removeElement($conversationUser)) {
  167.             // set the owning side to null (unless already changed)
  168.             if ($conversationUser->getUser() === $this) {
  169.                 $conversationUser->setUser(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174.     public function getHashTag(): ?string
  175.     {
  176.         return $this->hashTag;
  177.     }
  178.     public function setHashTag(string $hashTag): void
  179.     {
  180.         $this->hashTag $hashTag;
  181.     }
  182.     /**
  183.      * @return Collection<int, ChatNotification>
  184.      */
  185.     public function getChatNotifications(): Collection
  186.     {
  187.         return $this->chatNotifications;
  188.     }
  189.     public function addChatNotification(ChatNotification $chatNotification): self
  190.     {
  191.         if (!$this->chatNotifications->contains($chatNotification)) {
  192.             $this->chatNotifications[] = $chatNotification;
  193.             $chatNotification->setUser($this);
  194.         }
  195.         return $this;
  196.     }
  197.     public function removeChatNotification(ChatNotification $chatNotification): self
  198.     {
  199.         if ($this->chatNotifications->removeElement($chatNotification)) {
  200.             // set the owning side to null (unless already changed)
  201.             if ($chatNotification->getUser() === $this) {
  202.                 $chatNotification->setUser(null);
  203.             }
  204.         }
  205.         return $this;
  206.     }
  207.     public function getLastSelectedChannel(): ?Channel
  208.     {
  209.         return $this->lastSelectedChannel;
  210.     }
  211.     public function setLastSelectedChannel(?Channel $lastSelectedChannel): void
  212.     {
  213.         $this->lastSelectedChannel $lastSelectedChannel;
  214.     }
  215. }