-
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.
OXDEV-805 Prepaid data collectors for all tables in application layer
- Loading branch information
1 parent
2abbb50
commit f9bd87f
Showing
51 changed files
with
1,466 additions
and
23 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/UserData/Application/AbstractAggregateTableDataCollector.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,54 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Application; | ||
|
||
use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface; | ||
|
||
abstract class AbstractAggregateTableDataCollector implements TableDataCollectorInterface | ||
{ | ||
public function __construct( | ||
protected readonly UserDataRepositoryInterface $repository, | ||
protected array $collectors | ||
) { | ||
} | ||
|
||
abstract public function getTableName(): string; | ||
|
||
abstract protected function getColumnName(): string; | ||
|
||
public function collect(string $id): array | ||
{ | ||
$orderData = $this->repository->getDataFromTable( | ||
table: $this->getTableName(), | ||
columnName: $this->getColumnName(), | ||
columnValue: $id | ||
); | ||
|
||
$relatedData = []; | ||
if ($orderData) { | ||
foreach ($this->collectors as $collector) { | ||
if ($collector instanceof RelatedTableDataCollectorInterface) { | ||
$relatedData[$collector->getTableName()] = | ||
$collector->collectRelatedData( | ||
primaryTable: $this->getTableName(), | ||
primaryKey: $this->getColumnName(), | ||
primaryConditionColumn: $this->getColumnName(), | ||
primaryConditionValue: $id | ||
); | ||
} | ||
} | ||
} | ||
|
||
return [ | ||
$this->getTableName() => $orderData, | ||
'related_data' => $relatedData, | ||
]; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/UserData/Application/AbstractRelatedTableDataCollector.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,40 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Application; | ||
|
||
use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface; | ||
|
||
abstract class AbstractRelatedTableDataCollector implements RelatedTableDataCollectorInterface | ||
{ | ||
public function __construct( | ||
protected readonly UserDataRepositoryInterface $repository | ||
) { | ||
} | ||
|
||
abstract public function getTableName(): string; | ||
|
||
abstract protected function getColumnName(): string; | ||
|
||
public function collectRelatedData( | ||
string $primaryTable, | ||
string $primaryKey, | ||
string $primaryConditionColumn, | ||
string $primaryConditionValue | ||
): array { | ||
return $this->repository->getJoinedData( | ||
$primaryTable, | ||
$primaryKey, | ||
$this->getTableName(), | ||
$this->getColumnName(), | ||
$primaryConditionColumn, | ||
$primaryConditionValue | ||
); | ||
} | ||
} |
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\Application; | ||
|
||
use OxidEsales\GdprOptinModule\UserData\Infrastructure\UserDataRepositoryInterface; | ||
|
||
abstract class AbstractTableDataCollector implements TableDataCollectorInterface | ||
{ | ||
public function __construct( | ||
protected readonly UserDataRepositoryInterface $repository | ||
) { | ||
} | ||
|
||
abstract public function getTableName(): string; | ||
|
||
abstract protected function getColumnName(): string; | ||
|
||
public function collect(string $id): array | ||
{ | ||
return $this->repository->getDataFromTable($this->getTableName(), $this->getColumnName(), $id); | ||
} | ||
} |
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\Application; | ||
|
||
class AddressDataCollector extends AbstractTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxaddress'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class BasketDataCollector extends AbstractAggregateTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxuserbaskets'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class BasketItemsDataCollector extends AbstractRelatedTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxuserbasketitems'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXBASKETID'; | ||
} | ||
} |
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\Application; | ||
|
||
class NewsSubscribedDataCollector extends AbstractTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxnewssubscribed'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class OrderArticlesDataCollector extends AbstractRelatedTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxorderarticles'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXORDERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class OrderDataCollector extends AbstractAggregateTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxorder'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class OrderFilesDataCollector extends AbstractRelatedTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxorderfiles'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXORDERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class PriceAlarmDataCollector extends AbstractTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxpricealarm'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class RatingDataCollector extends AbstractTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxratings'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
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\Application; | ||
|
||
class RecommListDataCollector extends AbstractTableDataCollector | ||
{ | ||
public function getTableName(): string | ||
{ | ||
return 'oxrecommlists'; | ||
} | ||
|
||
protected function getColumnName(): string | ||
{ | ||
return 'OXUSERID'; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/UserData/Application/RelatedTableDataCollectorInterface.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,22 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\GdprOptinModule\UserData\Application; | ||
|
||
interface RelatedTableDataCollectorInterface | ||
{ | ||
public function collectRelatedData( | ||
string $primaryTable, | ||
string $primaryKey, | ||
string $primaryConditionColumn, | ||
string $primaryConditionValue | ||
): array; | ||
|
||
public function getTableName(): string; | ||
} |
Oops, something went wrong.