From d0aff0fa51ee61a68cce14c08e33a5bae555d4ce Mon Sep 17 00:00:00 2001 From: Matthieu Date: Wed, 3 Jun 2026 16:59:12 +0200 Subject: [PATCH] =?UTF-8?q?feat(share)=20:=20entit=C3=A9=20ShareConfigurat?= =?UTF-8?q?ion=20+=20migration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20260603165850.php | 29 ++++ src/Entity/ShareConfiguration.php | 139 ++++++++++++++++++ .../ShareConfigurationRepository.php | 26 ++++ 3 files changed, 194 insertions(+) create mode 100644 migrations/Version20260603165850.php create mode 100644 src/Entity/ShareConfiguration.php create mode 100644 src/Repository/ShareConfigurationRepository.php diff --git a/migrations/Version20260603165850.php b/migrations/Version20260603165850.php new file mode 100644 index 0000000..14815d7 --- /dev/null +++ b/migrations/Version20260603165850.php @@ -0,0 +1,29 @@ +addSql('CREATE TABLE share_configuration (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, host VARCHAR(255) DEFAULT NULL, share_name VARCHAR(255) DEFAULT NULL, base_path VARCHAR(255) DEFAULT NULL, domain VARCHAR(255) DEFAULT NULL, username VARCHAR(255) DEFAULT NULL, encrypted_password TEXT DEFAULT NULL, enabled BOOLEAN NOT NULL, PRIMARY KEY(id))'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE share_configuration'); + } +} diff --git a/src/Entity/ShareConfiguration.php b/src/Entity/ShareConfiguration.php new file mode 100644 index 0000000..3ff8ea5 --- /dev/null +++ b/src/Entity/ShareConfiguration.php @@ -0,0 +1,139 @@ +id; + } + + public function getHost(): ?string + { + return $this->host; + } + + public function setHost(?string $host): static + { + $this->host = $host; + + return $this; + } + + public function getShareName(): ?string + { + return $this->shareName; + } + + public function setShareName(?string $shareName): static + { + $this->shareName = $shareName; + + return $this; + } + + public function getBasePath(): ?string + { + return $this->basePath; + } + + public function setBasePath(?string $basePath): static + { + $this->basePath = $basePath; + + return $this; + } + + public function getDomain(): ?string + { + return $this->domain; + } + + public function setDomain(?string $domain): static + { + $this->domain = $domain; + + return $this; + } + + public function getUsername(): ?string + { + return $this->username; + } + + public function setUsername(?string $username): static + { + $this->username = $username; + + return $this; + } + + public function getEncryptedPassword(): ?string + { + return $this->encryptedPassword; + } + + public function setEncryptedPassword(?string $encryptedPassword): static + { + $this->encryptedPassword = $encryptedPassword; + + return $this; + } + + public function isEnabled(): bool + { + return $this->enabled; + } + + public function setEnabled(bool $enabled): static + { + $this->enabled = $enabled; + + return $this; + } + + public function hasPassword(): bool + { + return null !== $this->encryptedPassword; + } + + public function isUsable(): bool + { + return $this->enabled + && null !== $this->host && '' !== $this->host + && null !== $this->shareName && '' !== $this->shareName; + } +} diff --git a/src/Repository/ShareConfigurationRepository.php b/src/Repository/ShareConfigurationRepository.php new file mode 100644 index 0000000..066236b --- /dev/null +++ b/src/Repository/ShareConfigurationRepository.php @@ -0,0 +1,26 @@ +createQueryBuilder('s') + ->setMaxResults(1) + ->getQuery() + ->getOneOrNullResult() + ; + } +}