Skip to content

Commit 50d7616

Browse files
committed
Add hook
1 parent cab3957 commit 50d7616

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

app/Services/PersonalDataSelection/Exporters/Base/AbstractExporter.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace App\Services\PersonalDataSelection\Exporters\Base;
66

77
use App\Models\User;
8-
use Illuminate\Database\Eloquent\Collection;
98

109
abstract class AbstractExporter
1110
{
@@ -24,5 +23,13 @@ public function getFileName(): string {
2423
return $this->fileName;
2524
}
2625

27-
abstract protected function exportData(): array|string|Collection;
26+
public function getData(): array|string {
27+
$this->onExportValidation();
28+
29+
return $this->exportData();
30+
}
31+
32+
abstract protected function exportData(): array|string;
33+
34+
abstract protected function onExportValidation(): void;
2835
}

app/Services/PersonalDataSelection/Exporters/Base/Exporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function export(array $exporters): void {
2929
/** @var AbstractExporter $exporter */
3030
foreach ($this->exporters as $exporter) {
3131
$exporter = new $exporter($this->user);
32-
$this->personalDataSelection->add($exporter->getFileName(), $exporter->exportData());
32+
$this->personalDataSelection->add($exporter->getFileName(), $exporter->getData());
3333
}
3434
}
3535

app/Services/PersonalDataSelection/Exporters/Base/ModelExportable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@
66

77
trait ModelExportable
88
{
9-
9+
protected function onExportValidation(): void {
10+
// todo check for model + columns
11+
}
1012
}

app/Services/PersonalDataSelection/Exporters/StatusExporter.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
namespace App\Services\PersonalDataSelection\Exporters;
66

77
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter;
8+
use App\Services\PersonalDataSelection\Exporters\Base\ModelExportable;
89

910
class StatusExporter extends AbstractExporter
1011
{
12+
use ModelExportable;
13+
1114
protected string $fileName = 'statuses.json';
1215

13-
public function exportData(): array|string {
16+
protected function exportData(): array|string {
1417
return $this->user->statuses()->with('tags')->get()->toArray(); // todo: columns definieren
1518
}
1619
}

0 commit comments

Comments
 (0)