diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index 12c9ae4..62cdfd1 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -326,6 +326,7 @@
+
diff --git a/config/packages/security.yaml b/config/packages/security.yaml
index 367af25..663fbf5 100644
--- a/config/packages/security.yaml
+++ b/config/packages/security.yaml
@@ -4,14 +4,18 @@ security:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
- users_in_memory: { memory: null }
+ # used to reload user from session & other features (e.g. switch_user)
+ app_user_provider:
+ entity:
+ class: App\Entity\User
+ property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
- provider: users_in_memory
+ provider: app_user_provider
# activate different ways to authenticate
# https://symfony.com/doc/current/security.html#the-firewall
diff --git a/diagrams/database.drawio b/diagrams/database.drawio
index 53afd0e..b7f641f 100644
--- a/diagrams/database.drawio
+++ b/diagrams/database.drawio
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/Entity/Document.php b/src/Entity/Document.php
new file mode 100644
index 0000000..18fd530
--- /dev/null
+++ b/src/Entity/Document.php
@@ -0,0 +1,131 @@
+tags = new ArrayCollection();
+ }
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getUser(): ?User
+ {
+ return $this->user;
+ }
+
+ public function setUser(?User $user): self
+ {
+ $this->user = $user;
+
+ return $this;
+ }
+
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ public function setName(string $name): self
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ public function getDescription(): ?string
+ {
+ return $this->description;
+ }
+
+ public function setDescription(?string $description): self
+ {
+ $this->description = $description;
+
+ return $this;
+ }
+
+ public function getCreation(): ?\DateTimeInterface
+ {
+ return $this->creation;
+ }
+
+ public function setCreation(\DateTimeInterface $creation): self
+ {
+ $this->creation = $creation;
+
+ return $this;
+ }
+
+ public function getModification(): ?\DateTimeInterface
+ {
+ return $this->modification;
+ }
+
+ public function setModification(\DateTimeInterface $modification): self
+ {
+ $this->modification = $modification;
+
+ return $this;
+ }
+
+ /**
+ * @return Collection
+ */
+ public function getTags(): Collection
+ {
+ return $this->tags;
+ }
+
+ public function addTag(Tag $tag): self
+ {
+ if (!$this->tags->contains($tag)) {
+ $this->tags->add($tag);
+ }
+
+ return $this;
+ }
+
+ public function removeTag(Tag $tag): self
+ {
+ $this->tags->removeElement($tag);
+
+ return $this;
+ }
+}
diff --git a/src/Entity/Tag.php b/src/Entity/Tag.php
new file mode 100644
index 0000000..37e6b8d
--- /dev/null
+++ b/src/Entity/Tag.php
@@ -0,0 +1,72 @@
+documents = new ArrayCollection();
+ }
+
+ public function getId(): ?int
+ {
+ return $this->id;
+ }
+
+ public function getName(): ?string
+ {
+ return $this->name;
+ }
+
+ public function setName(string $name): self
+ {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * @return Collection
+ */
+ public function getDocuments(): Collection
+ {
+ return $this->documents;
+ }
+
+ public function addDocument(Document $document): self
+ {
+ if (!$this->documents->contains($document)) {
+ $this->documents->add($document);
+ $document->addTag($this);
+ }
+
+ return $this;
+ }
+
+ public function removeDocument(Document $document): self
+ {
+ if ($this->documents->removeElement($document)) {
+ $document->removeTag($this);
+ }
+
+ return $this;
+ }
+}
diff --git a/src/Entity/User.php b/src/Entity/User.php
new file mode 100644
index 0000000..f765df9
--- /dev/null
+++ b/src/Entity/User.php
@@ -0,0 +1,99 @@
+id;
+ }
+
+ public function getUsername(): ?string
+ {
+ return $this->username;
+ }
+
+ public function setUsername(string $username): self
+ {
+ $this->username = $username;
+
+ return $this;
+ }
+
+ /**
+ * A visual identifier that represents this user.
+ *
+ * @see UserInterface
+ */
+ public function getUserIdentifier(): 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;
+ }
+
+ /**
+ * @see UserInterface
+ */
+ public function eraseCredentials()
+ {
+ // If you store any temporary, sensitive data on the user, clear it here
+ // $this->plainPassword = null;
+ }
+}
diff --git a/src/Repository/DocumentRepository.php b/src/Repository/DocumentRepository.php
new file mode 100644
index 0000000..0c7023a
--- /dev/null
+++ b/src/Repository/DocumentRepository.php
@@ -0,0 +1,66 @@
+
+ *
+ * @method Document|null find($id, $lockMode = null, $lockVersion = null)
+ * @method Document|null findOneBy(array $criteria, array $orderBy = null)
+ * @method Document[] findAll()
+ * @method Document[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class DocumentRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, Document::class);
+ }
+
+ public function save(Document $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(Document $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+// /**
+// * @return Document[] Returns an array of Document objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('d')
+// ->andWhere('d.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('d.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?Document
+// {
+// return $this->createQueryBuilder('d')
+// ->andWhere('d.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Repository/TagRepository.php b/src/Repository/TagRepository.php
new file mode 100644
index 0000000..d041303
--- /dev/null
+++ b/src/Repository/TagRepository.php
@@ -0,0 +1,66 @@
+
+ *
+ * @method Tag|null find($id, $lockMode = null, $lockVersion = null)
+ * @method Tag|null findOneBy(array $criteria, array $orderBy = null)
+ * @method Tag[] findAll()
+ * @method Tag[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class TagRepository extends ServiceEntityRepository
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, Tag::class);
+ }
+
+ public function save(Tag $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(Tag $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+// /**
+// * @return Tag[] Returns an array of Tag objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('t')
+// ->andWhere('t.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('t.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?Tag
+// {
+// return $this->createQueryBuilder('t')
+// ->andWhere('t.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}
diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php
new file mode 100644
index 0000000..9b60483
--- /dev/null
+++ b/src/Repository/UserRepository.php
@@ -0,0 +1,83 @@
+
+ *
+ * @method User|null find($id, $lockMode = null, $lockVersion = null)
+ * @method User|null findOneBy(array $criteria, array $orderBy = null)
+ * @method User[] findAll()
+ * @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
+ */
+class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
+{
+ public function __construct(ManagerRegistry $registry)
+ {
+ parent::__construct($registry, User::class);
+ }
+
+ public function save(User $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->persist($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ public function remove(User $entity, bool $flush = false): void
+ {
+ $this->getEntityManager()->remove($entity);
+
+ if ($flush) {
+ $this->getEntityManager()->flush();
+ }
+ }
+
+ /**
+ * Used to upgrade (rehash) the user's password automatically over time.
+ */
+ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void
+ {
+ if (!$user instanceof User) {
+ throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
+ }
+
+ $user->setPassword($newHashedPassword);
+
+ $this->save($user, true);
+ }
+
+// /**
+// * @return User[] Returns an array of User objects
+// */
+// public function findByExampleField($value): array
+// {
+// return $this->createQueryBuilder('u')
+// ->andWhere('u.exampleField = :val')
+// ->setParameter('val', $value)
+// ->orderBy('u.id', 'ASC')
+// ->setMaxResults(10)
+// ->getQuery()
+// ->getResult()
+// ;
+// }
+
+// public function findOneBySomeField($value): ?User
+// {
+// return $this->createQueryBuilder('u')
+// ->andWhere('u.exampleField = :val')
+// ->setParameter('val', $value)
+// ->getQuery()
+// ->getOneOrNullResult()
+// ;
+// }
+}