-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'b-7.2.x-extral-all-user-data-OXDEV-805' into b-7.2.x
- Loading branch information
Showing
54 changed files
with
2,039 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
imports: | ||
- { resource: src/UserData/services.yaml } | ||
|
||
services: | ||
|
||
_defaults: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Controller; | ||
|
||
use OxidEsales\Eshop\Application\Controller\Admin\AdminController; | ||
use OxidEsales\GdprOptinModule\UserData\Service\UserDataExportServiceInterface; | ||
|
||
class UserDataExportController extends AdminController | ||
{ | ||
public function exportUserData(): void | ||
{ | ||
$userId = $this->getEditObjectId(); | ||
$userDataExportService = $this->getService(UserDataExportServiceInterface::class); | ||
$userDataExportService->exportUserData(userId: $userId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\DataType; | ||
|
||
class ResultFile implements ResultFileInterface | ||
{ | ||
public function __construct( | ||
private readonly string $fileName, | ||
private readonly string $content | ||
) { | ||
} | ||
|
||
public function getFileName(): string | ||
{ | ||
return $this->fileName; | ||
} | ||
|
||
public function getContent(): string | ||
{ | ||
return $this->content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\DataType; | ||
|
||
interface ResultFileInterface | ||
{ | ||
public function getFileName(): string; | ||
|
||
public function getContent(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\DataType; | ||
|
||
class TableDataCollection implements TableDataCollectionInterface | ||
{ | ||
/** | ||
* @param array<string, array<array<string, string>>> $dataCollection | ||
*/ | ||
public function __construct( | ||
protected string $collectionName, | ||
protected array $dataCollection | ||
) { | ||
} | ||
|
||
public function getCollectionName(): string | ||
{ | ||
return $this->collectionName; | ||
} | ||
|
||
public function getCollection(): array | ||
{ | ||
return $this->dataCollection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\DataType; | ||
|
||
interface TableDataCollectionInterface | ||
{ | ||
public function getCollectionName(): string; | ||
|
||
/** | ||
* @return array<string, array<array<string, string>>> | ||
*/ | ||
public function getCollection(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Event; | ||
|
||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class UserDataExportCleanupEvent extends Event implements UserDataExportCleanupEventInterface | ||
{ | ||
public function __construct( | ||
private readonly string $filePath | ||
) { | ||
} | ||
|
||
public function getFilePath(): string | ||
{ | ||
return $this->filePath; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/UserData/Event/UserDataExportCleanupEventInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Event; | ||
|
||
interface UserDataExportCleanupEventInterface | ||
{ | ||
public function getFilePath(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Event; | ||
|
||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
|
||
class UserDataExportCleanupSubscriber implements EventSubscriberInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
UserDataExportCleanupEvent::class => 'onUserDataExportCleanup', | ||
]; | ||
} | ||
|
||
public function onUserDataExportCleanup(UserDataExportCleanupEventInterface&Event $event): void | ||
{ | ||
$filePath = $event->getFilePath(); | ||
|
||
if (file_exists($filePath)) { | ||
unlink($filePath); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Exception; | ||
|
||
class AggregationTypeException extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Exception; | ||
|
||
class JsonSerializationException extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Exception; | ||
|
||
class UserDataFileDownloadException extends \Exception | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Exception; | ||
|
||
use RuntimeException; | ||
|
||
class ZipCreationException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Infrastructure; | ||
|
||
interface DataSelectorInterface | ||
{ | ||
public function getCollection(): string; | ||
|
||
public function getSelectionTable(): string; | ||
|
||
/** | ||
* @return array<array<string, string>> | ||
*/ | ||
public function getDataForColumnValue(string $columnValue): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Infrastructure; | ||
|
||
use Doctrine\DBAL\ForwardCompatibility\Result; | ||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; | ||
|
||
class GeneralTableDataSelector implements DataSelectorInterface | ||
{ | ||
/** | ||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) Not different behaviour, just protection from explosion | ||
*/ | ||
public function __construct( | ||
private string $collection, | ||
private string $selectionTable, | ||
private string $filterColumn, | ||
private QueryBuilderFactoryInterface $queryBuilderFactory, | ||
private bool $optional = false, | ||
) { | ||
} | ||
|
||
public function getCollection(): string | ||
{ | ||
return $this->collection; | ||
} | ||
|
||
public function getSelectionTable(): string | ||
{ | ||
return $this->selectionTable; | ||
} | ||
|
||
public function getDataForColumnValue(string $columnValue): array | ||
{ | ||
$queryBuilder = $this->queryBuilderFactory->create(); | ||
|
||
try { | ||
$queryBuilder->select('*') | ||
->from($this->selectionTable) | ||
->where($this->filterColumn . ' = :filterValue') | ||
->setParameter('filterValue', $columnValue); | ||
|
||
/** @var Result $result */ | ||
$result = $queryBuilder->execute(); /** @phpstan-ignore missingType.iterableValue */ | ||
|
||
return $result->fetchAllAssociative(); | ||
} catch (\Exception $e) { | ||
if (!$this->optional) { | ||
throw $e; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
} |
Oops, something went wrong.