src/Entity/User.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Document;
  4. use App\Entity\Document\BlockCategory;
  5. use App\Repository\UserRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\OneToMany(mappedBy'owner'targetEntityDocxUploaded::class)]
  28.     private Collection $docxUploadeds;
  29.     #[ORM\OneToMany(mappedBy'owner'targetEntityDocument::class)]
  30.     private Collection $documents;
  31.     #[ORM\OneToMany(mappedBy'owner'targetEntityDocument::class)]
  32.     private Collection $docs;
  33.     #[ORM\OneToMany(mappedBy'user'targetEntityDocumentPermission::class, orphanRemovaltrue)]
  34.     private Collection $documentPermissions;
  35.     #[ORM\OneToMany(mappedBy'owner'targetEntityBlockCategory::class)]
  36.     private Collection $blockCategories;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $apikey null;
  39.     public function __construct()
  40.     {
  41.         $this->docxUploadeds = new ArrayCollection();
  42.         $this->documents = new ArrayCollection();
  43.         $this->docs = new ArrayCollection();
  44.         $this->documentPermissions = new ArrayCollection();
  45.         $this->blockCategories = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getEmail(): ?string
  52.     {
  53.         return $this->email;
  54.     }
  55.     public function setEmail(string $email): self
  56.     {
  57.         $this->email $email;
  58.         return $this;
  59.     }
  60.     /**
  61.      * A visual identifier that represents this user.
  62.      *
  63.      * @see UserInterface
  64.      */
  65.     public function getUserIdentifier(): string
  66.     {
  67.         return (string) $this->email;
  68.     }
  69.     /**
  70.      * @see UserInterface
  71.      */
  72.     public function getRoles(): array
  73.     {
  74.         $roles $this->roles;
  75.         // guarantee every user at least has ROLE_USER
  76.         $roles[] = 'ROLE_USER';
  77.         return array_unique($roles);
  78.     }
  79.     public function setRoles(array $roles): self
  80.     {
  81.         $this->roles $roles;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @see PasswordAuthenticatedUserInterface
  86.      */
  87.     public function getPassword(): string
  88.     {
  89.         return $this->password;
  90.     }
  91.     public function setPassword(string $password): self
  92.     {
  93.         $this->password $password;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @see UserInterface
  98.      */
  99.     public function eraseCredentials()
  100.     {
  101.         // If you store any temporary, sensitive data on the user, clear it here
  102.         // $this->plainPassword = null;
  103.     }
  104.     /**
  105.      * @return Collection<int, DocxUploaded>
  106.      */
  107.     public function getDocxUploadeds(): Collection
  108.     {
  109.         return $this->docxUploadeds;
  110.     }
  111.     public function addDocxUploaded(DocxUploaded $docxUploaded): self
  112.     {
  113.         if (!$this->docxUploadeds->contains($docxUploaded)) {
  114.             $this->docxUploadeds->add($docxUploaded);
  115.             $docxUploaded->setOwner($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeDocxUploaded(DocxUploaded $docxUploaded): self
  120.     {
  121.         if ($this->docxUploadeds->removeElement($docxUploaded)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($docxUploaded->getOwner() === $this) {
  124.                 $docxUploaded->setOwner(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return Collection<int, Document>
  131.      */
  132.     public function getDocuments(): Collection
  133.     {
  134.         return $this->documents;
  135.     }
  136.     public function addDocument(Document $document): self
  137.     {
  138.         if (!$this->documents->contains($document)) {
  139.             $this->documents->add($document);
  140.             $document->setOwner($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeDocument(Document $document): self
  145.     {
  146.         if ($this->documents->removeElement($document)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($document->getOwner() === $this) {
  149.                 $document->setOwner(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, Document>
  156.      */
  157.     public function getDocs(): Collection
  158.     {
  159.         return $this->docs;
  160.     }
  161.     public function addDoc(Document $doc): self
  162.     {
  163.         if (!$this->docs->contains($doc)) {
  164.             $this->docs->add($doc);
  165.             $doc->setOwner($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeDoc(Document $doc): self
  170.     {
  171.         if ($this->docs->removeElement($doc)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($doc->getOwner() === $this) {
  174.                 $doc->setOwner(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return Collection<int, DocumentPermission>
  181.      */
  182.     public function getDocumentPermissions(): Collection
  183.     {
  184.         return $this->documentPermissions;
  185.     }
  186.     public function addDocumentPermission(DocumentPermission $documentPermission): self
  187.     {
  188.         if (!$this->documentPermissions->contains($documentPermission)) {
  189.             $this->documentPermissions->add($documentPermission);
  190.             $documentPermission->setUser($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeDocumentPermission(DocumentPermission $documentPermission): self
  195.     {
  196.         if ($this->documentPermissions->removeElement($documentPermission)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($documentPermission->getUser() === $this) {
  199.                 $documentPermission->setUser(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection<int, BlockCategory>
  206.      */
  207.     public function getBlockCategories(): Collection
  208.     {
  209.         return $this->blockCategories;
  210.     }
  211.     public function addBlockCategory(BlockCategory $blockCategory): static
  212.     {
  213.         if (!$this->blockCategories->contains($blockCategory)) {
  214.             $this->blockCategories->add($blockCategory);
  215.             $blockCategory->setOwner($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeBlockCategory(BlockCategory $blockCategory): static
  220.     {
  221.         if ($this->blockCategories->removeElement($blockCategory)) {
  222.             // set the owning side to null (unless already changed)
  223.             if ($blockCategory->getOwner() === $this) {
  224.                 $blockCategory->setOwner(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     public function getApikey(): ?string
  230.     {
  231.         return $this->apikey;
  232.     }
  233.     public function setApikey(?string $apikey): static
  234.     {
  235.         $this->apikey $apikey;
  236.         return $this;
  237.     }
  238. }