-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rick in t Veld
committed
Apr 25, 2024
1 parent
03e8f59
commit 39d6fa4
Showing
7 changed files
with
92 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Action\Download; | ||
|
||
use App\Action\ActionInterface; | ||
use App\Dto\Aggregator\AggregateInterface; | ||
use App\FileSystem\File; | ||
use App\Manager\FileDownloadManager; | ||
|
||
final class FileDownloadAction implements ActionInterface | ||
{ | ||
public function __construct(private readonly FileDownloadManager $fileDownloadManager) | ||
{ | ||
} | ||
|
||
public function __invoke(AggregateInterface $aggregator): void | ||
{ | ||
if (($aggregator->getData() instanceof File) === false) { | ||
throw new \RuntimeException('Data should be an instance of class ' . File::class); | ||
} | ||
|
||
($this->fileDownloadManager)($aggregator->getData()); | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Action\FileSystem; | ||
|
||
use App\Action\ActionInterface; | ||
use App\Dto\Aggregator\AggregateInterface; | ||
use App\FileSystem\CsvFile; | ||
use App\Serializer\Serializer; | ||
|
||
class CreateCsvFileAction implements ActionInterface | ||
{ | ||
public function __construct(private readonly Serializer $serializer) | ||
{ | ||
} | ||
|
||
public function __invoke(AggregateInterface $aggregator): void | ||
{ | ||
$csvFile = new CsvFile(); | ||
|
||
$csvFile->setFileName(sprintf('export_%d', (new \DateTime())->getTimestamp())); | ||
|
||
$csvFile->setContents( | ||
$this->serializer->encode($aggregator->getData(), 'csv', ['csv_delimiter' => ',']) | ||
); | ||
|
||
$aggregator->setData($csvFile); | ||
} | ||
} |
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