Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: entity repository #193

Merged
merged 8 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/PsgdprConsentLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

/**
* @ORM\Table()
* @ORM\Entity(repositoryClass="PrestaShop\Module\Psgdpr\Repository\ConsentLangRepository")
* @ORM\Entity()
*/
class PsgdprConsentLang
{
Expand Down
50 changes: 0 additions & 50 deletions src/Repository/ConsentLangRepository.php

This file was deleted.

6 changes: 2 additions & 4 deletions src/Repository/ConsentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -64,8 +64,6 @@ public function createOrUpdateConsent(PsgdprConsent $psgdprConsent): bool

$this->getEntityManager()->persist($consent);
$this->getEntityManager()->flush();

return true;
}

/**
Expand Down
6 changes: 2 additions & 4 deletions src/Repository/LoggerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ public function __construct(ManagerRegistry $registry)
*
* @param PsgdprLog $log
*
* @return bool
* @return void
*/
public function add(PsgdprLog $log): bool
public function add(PsgdprLog $log)
{
$this->getEntityManager()->persist($log);
$this->getEntityManager()->flush();

return true;
}

/**
Expand Down
11 changes: 8 additions & 3 deletions src/Service/ExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
use Language;
use Module;
use Order;
use PDF;
use PDFGenerator;
use PdfGeneratorService;
use PrestaShop\PrestaShop\Adapter\Entity\CustomerThread;
use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId;
use PrestaShopBundle\Translation\TranslatorInterface;
Expand Down Expand Up @@ -250,7 +248,14 @@ 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);

$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();
Expand Down
16 changes: 9 additions & 7 deletions src/Service/PdfGeneratorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand All @@ -40,8 +49,6 @@ class PdfGeneratorService extends HTMLTemplate
/**
* @param array $customerData
* @param Smarty $smarty
*
* @throws PrestaShopException
*/
public function __construct($customerData, Smarty $smarty)
{
Expand All @@ -61,8 +68,6 @@ public function __construct($customerData, Smarty $smarty)
* Returns the template's HTML footer
*
* @return string HTML footer
*
* @throws SmartyException
*/
public function getFooter()
{
Expand All @@ -83,8 +88,6 @@ public function getFooter()
* Returns the template's HTML content
*
* @return string HTML content
*
* @throws SmartyException
*/
public function getContent()
{
Expand Down Expand Up @@ -113,7 +116,6 @@ public function getContent()
}
}

// Generate smarty data
$this->smarty->assign([
'customerInfo' => [
'headers' => $this->customerData['personalinformations']['headers'],
Expand Down