Skip to content

Commit

Permalink
Add hook
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrLevin committed Nov 29, 2024
1 parent cab3957 commit 50d7616
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace App\Services\PersonalDataSelection\Exporters\Base;

use App\Models\User;
use Illuminate\Database\Eloquent\Collection;

abstract class AbstractExporter
{
Expand All @@ -24,5 +23,13 @@ public function getFileName(): string {
return $this->fileName;
}

abstract protected function exportData(): array|string|Collection;
public function getData(): array|string {
$this->onExportValidation();

return $this->exportData();
}

abstract protected function exportData(): array|string;

abstract protected function onExportValidation(): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function export(array $exporters): void {
/** @var AbstractExporter $exporter */
foreach ($this->exporters as $exporter) {
$exporter = new $exporter($this->user);
$this->personalDataSelection->add($exporter->getFileName(), $exporter->exportData());
$this->personalDataSelection->add($exporter->getFileName(), $exporter->getData());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@

trait ModelExportable
{

protected function onExportValidation(): void {
// todo check for model + columns
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
namespace App\Services\PersonalDataSelection\Exporters;

use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter;
use App\Services\PersonalDataSelection\Exporters\Base\ModelExportable;

class StatusExporter extends AbstractExporter
{
use ModelExportable;

protected string $fileName = 'statuses.json';

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

0 comments on commit 50d7616

Please sign in to comment.