From e7ca89f7608211a2a08e5fb6878d533188ed6b60 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Wed, 22 Mar 2023 14:49:16 +0100 Subject: [PATCH 1/8] fix: add entity repository --- src/Repository/ConsentLangRepository.php | 5 ----- src/Repository/ConsentRepository.php | 6 ++---- src/Repository/LoggerRepository.php | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/Repository/ConsentLangRepository.php b/src/Repository/ConsentLangRepository.php index 0539e9fa..06740735 100644 --- a/src/Repository/ConsentLangRepository.php +++ b/src/Repository/ConsentLangRepository.php @@ -39,12 +39,7 @@ class ConsentLangRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) - { parent::__construct($registry, PsgdprConsentLang::class); - } - - public function findAll() { - return $this->findBy([]); } } diff --git a/src/Repository/ConsentRepository.php b/src/Repository/ConsentRepository.php index 66f5a7a0..75437158 100644 --- a/src/Repository/ConsentRepository.php +++ b/src/Repository/ConsentRepository.php @@ -37,9 +37,9 @@ public function __construct(ManagerRegistry $registry) * * @param PsgdprConsent $psgdprConsent * - * @return bool + * @return void */ - public function createOrUpdateConsent(PsgdprConsent $psgdprConsent): bool + public function createOrUpdateConsent(PsgdprConsent $psgdprConsent): void { /** @var PsgdprConsent|null $consent */ $consent = $this->findConsentByModuleId($psgdprConsent->getModuleId()); @@ -64,8 +64,6 @@ public function createOrUpdateConsent(PsgdprConsent $psgdprConsent): bool $this->getEntityManager()->persist($consent); $this->getEntityManager()->flush(); - - return true; } /** diff --git a/src/Repository/LoggerRepository.php b/src/Repository/LoggerRepository.php index 84b2c5ac..b9f079dc 100644 --- a/src/Repository/LoggerRepository.php +++ b/src/Repository/LoggerRepository.php @@ -36,9 +36,9 @@ public function __construct(ManagerRegistry $registry) * * @param PsgdprLog $log * - * @return bool + * @return void */ - public function add(PsgdprLog $log): bool + public function add(PsgdprLog $log): void { $this->getEntityManager()->persist($log); $this->getEntityManager()->flush(); From 115afa99dd09f4e2d6ebbf894c131172f76341c4 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Thu, 23 Mar 2023 15:52:39 +0100 Subject: [PATCH 2/8] fix: remove extra code --- src/Entity/PsgdprConsent.php | 1 - src/Entity/PsgdprLog.php | 1 - src/Repository/ConsentLangRepository.php | 3 +-- src/Repository/LoggerRepository.php | 4 +--- 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Entity/PsgdprConsent.php b/src/Entity/PsgdprConsent.php index 14daa4ae..3d3e8424 100644 --- a/src/Entity/PsgdprConsent.php +++ b/src/Entity/PsgdprConsent.php @@ -28,7 +28,6 @@ /** * @ORM\Table() * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\ConsentRepository") - * @ORM\HasLifecycleCallbacks() */ class PsgdprConsent { diff --git a/src/Entity/PsgdprLog.php b/src/Entity/PsgdprLog.php index ca5f14e2..7fb29917 100644 --- a/src/Entity/PsgdprLog.php +++ b/src/Entity/PsgdprLog.php @@ -29,7 +29,6 @@ /** * @ORM\Table() * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\LoggerRepository") - * @ORM\HasLifecycleCallbacks() */ class PsgdprLog { diff --git a/src/Repository/ConsentLangRepository.php b/src/Repository/ConsentLangRepository.php index 06740735..311208ac 100644 --- a/src/Repository/ConsentLangRepository.php +++ b/src/Repository/ConsentLangRepository.php @@ -28,7 +28,6 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; -use PrestaShop\Module\Psgdpr\Entity\PsgdprConsentLang; /** * ConsentLangRepository. @@ -39,7 +38,7 @@ class ConsentLangRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) - parent::__construct($registry, PsgdprConsentLang::class); { + parent::__construct($registry, PsgdprLog::class); } } diff --git a/src/Repository/LoggerRepository.php b/src/Repository/LoggerRepository.php index b9f079dc..f5f761f0 100644 --- a/src/Repository/LoggerRepository.php +++ b/src/Repository/LoggerRepository.php @@ -38,12 +38,10 @@ public function __construct(ManagerRegistry $registry) * * @return void */ - public function add(PsgdprLog $log): void + public function add(PsgdprLog $log) { $this->getEntityManager()->persist($log); $this->getEntityManager()->flush(); - - return true; } /** From 34aa0b331fe33d8963ef871103d2599ba622ec5d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 09:34:03 +0200 Subject: [PATCH 3/8] fix: php-stan --- src/Repository/ConsentLangRepository.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Repository/ConsentLangRepository.php b/src/Repository/ConsentLangRepository.php index 311208ac..6f3269aa 100644 --- a/src/Repository/ConsentLangRepository.php +++ b/src/Repository/ConsentLangRepository.php @@ -28,6 +28,7 @@ use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; +use PrestaShop\Module\Psgdpr\Entity\PsgdprLog; /** * ConsentLangRepository. From 4f48d673343c17314767806d128c347d9fb4c1a7 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 10:18:56 +0200 Subject: [PATCH 4/8] fix: problem on insert into bdd --- src/Entity/PsgdprConsent.php | 1 + src/Entity/PsgdprLog.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Entity/PsgdprConsent.php b/src/Entity/PsgdprConsent.php index 3d3e8424..14daa4ae 100644 --- a/src/Entity/PsgdprConsent.php +++ b/src/Entity/PsgdprConsent.php @@ -28,6 +28,7 @@ /** * @ORM\Table() * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\ConsentRepository") + * @ORM\HasLifecycleCallbacks() */ class PsgdprConsent { diff --git a/src/Entity/PsgdprLog.php b/src/Entity/PsgdprLog.php index 7fb29917..ca5f14e2 100644 --- a/src/Entity/PsgdprLog.php +++ b/src/Entity/PsgdprLog.php @@ -29,6 +29,7 @@ /** * @ORM\Table() * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\LoggerRepository") + * @ORM\HasLifecycleCallbacks() */ class PsgdprLog { From ec547fda00efc6119c85e488e4700d04e8ca071f Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 10:35:19 +0200 Subject: [PATCH 5/8] fix: remove useless service --- config/services.yml | 3 -- src/Entity/PsgdprConsentLang.php | 2 +- src/Repository/ConsentLangRepository.php | 45 ------------------------ 3 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 src/Repository/ConsentLangRepository.php diff --git a/config/services.yml b/config/services.yml index b2938bb7..e5bdea80 100644 --- a/config/services.yml +++ b/config/services.yml @@ -51,9 +51,6 @@ services: PrestaShop\Module\Psgdpr\Repository\ConsentRepository: class: 'PrestaShop\Module\Psgdpr\Repository\ConsentRepository' - PrestaShop\Module\Psgdpr\Repository\ConsentLangRepository: - class: 'PrestaShop\Module\Psgdpr\Repository\ConsentLangRepository' - ## CONTROLLERS ## PrestaShop\Module\Psgdpr\Controller\Admin\CustomerController: class: 'PrestaShop\Module\Psgdpr\Controller\Admin\CustomerController' diff --git a/src/Entity/PsgdprConsentLang.php b/src/Entity/PsgdprConsentLang.php index 40395441..85d5177f 100644 --- a/src/Entity/PsgdprConsentLang.php +++ b/src/Entity/PsgdprConsentLang.php @@ -25,7 +25,7 @@ /** * @ORM\Table() - * @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\ConsentLangRepository") + * @ORM\Entity() */ class PsgdprConsentLang { diff --git a/src/Repository/ConsentLangRepository.php b/src/Repository/ConsentLangRepository.php deleted file mode 100644 index 6f3269aa..00000000 --- a/src/Repository/ConsentLangRepository.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\Module\Psgdpr\Repository; - -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\Persistence\ManagerRegistry; -use PrestaShop\Module\Psgdpr\Entity\PsgdprLog; - -/** - * ConsentLangRepository. - * - * This class was generated by the Doctrine ORM. Add your own custom - * repository methods below. - */ -class ConsentLangRepository extends ServiceEntityRepository -{ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, PsgdprLog::class); - } -} From 33f619308880a9b203907dc2f609564d035eccb4 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 11:50:54 +0200 Subject: [PATCH 6/8] fix: error with export pdf --- src/Service/ExportService.php | 13 ++++++++++--- src/Service/PdfGeneratorService.php | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Service/ExportService.php b/src/Service/ExportService.php index 52e1927a..604016df 100644 --- a/src/Service/ExportService.php +++ b/src/Service/ExportService.php @@ -34,9 +34,8 @@ use Language; use Module; use Order; -use PDF; +use PrestaShop\Module\Psgdpr\Service\Smarty; use PDFGenerator; -use PdfGeneratorService; use PrestaShop\PrestaShop\Adapter\Entity\CustomerThread; use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; use PrestaShopBundle\Translation\TranslatorInterface; @@ -250,7 +249,15 @@ private function exportCustomerToPdf(CustomerId $customerId, array $customerData $this->context->smarty->escape_html = false; $pdfGenerator = new PDFGenerator(false, 'P'); - $template = new PdfGeneratorService($customerData, $this->context->smarty); + + /** @var Smarty $smarty */ + $smarty = $this->context->smarty; + + if ($smarty === null) { + throw new PrestaShopException('Smarty not initialized'); + } + + $template = new PdfGeneratorService($customerData, $smarty); $pdfGenerator->setFontForLang($this->context->language->iso_code); $pdfGenerator->startPageGroup(); diff --git a/src/Service/PdfGeneratorService.php b/src/Service/PdfGeneratorService.php index 8441c5e8..99906a4b 100755 --- a/src/Service/PdfGeneratorService.php +++ b/src/Service/PdfGeneratorService.php @@ -20,6 +20,15 @@ // require _PS_MODULE_DIR_.'psgdpr/psgdpr.php'; +namespace PrestaShop\Module\Psgdpr\Service; + +use Configuration; +use Context; +use HTMLTemplate; +use Shop; +use Smarty; +use Tools; + class PdfGeneratorService extends HTMLTemplate { /** From 5b5f561d8ef1eadfdb51577609e8669520f6f146 Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 12:03:58 +0200 Subject: [PATCH 7/8] fix: php-stan --- src/Service/ExportService.php | 2 -- src/Service/PdfGeneratorService.php | 6 ------ 2 files changed, 8 deletions(-) diff --git a/src/Service/ExportService.php b/src/Service/ExportService.php index 604016df..e0f66abf 100644 --- a/src/Service/ExportService.php +++ b/src/Service/ExportService.php @@ -34,7 +34,6 @@ use Language; use Module; use Order; -use PrestaShop\Module\Psgdpr\Service\Smarty; use PDFGenerator; use PrestaShop\PrestaShop\Adapter\Entity\CustomerThread; use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; @@ -250,7 +249,6 @@ private function exportCustomerToPdf(CustomerId $customerId, array $customerData $pdfGenerator = new PDFGenerator(false, 'P'); - /** @var Smarty $smarty */ $smarty = $this->context->smarty; if ($smarty === null) { diff --git a/src/Service/PdfGeneratorService.php b/src/Service/PdfGeneratorService.php index 99906a4b..d94616d2 100755 --- a/src/Service/PdfGeneratorService.php +++ b/src/Service/PdfGeneratorService.php @@ -49,8 +49,6 @@ class PdfGeneratorService extends HTMLTemplate /** * @param array $customerData * @param Smarty $smarty - * - * @throws PrestaShopException */ public function __construct($customerData, Smarty $smarty) { @@ -70,8 +68,6 @@ public function __construct($customerData, Smarty $smarty) * Returns the template's HTML footer * * @return string HTML footer - * - * @throws SmartyException */ public function getFooter() { @@ -92,8 +88,6 @@ public function getFooter() * Returns the template's HTML content * * @return string HTML content - * - * @throws SmartyException */ public function getContent() { From e128ba4e4520d748ec168705c4459ea4f906c81d Mon Sep 17 00:00:00 2001 From: "John.R" Date: Mon, 27 Mar 2023 14:52:38 +0200 Subject: [PATCH 8/8] chore: relaunch ci --- src/Service/PdfGeneratorService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Service/PdfGeneratorService.php b/src/Service/PdfGeneratorService.php index d94616d2..4adb37e8 100755 --- a/src/Service/PdfGeneratorService.php +++ b/src/Service/PdfGeneratorService.php @@ -116,7 +116,6 @@ public function getContent() } } - // Generate smarty data $this->smarty->assign([ 'customerInfo' => [ 'headers' => $this->customerData['personalinformations']['headers'],