allow custom export repositories (#2182)

This commit is contained in:
Kevin Papst
2020-12-10 15:00:14 +01:00
committed by GitHub
parent c3fe8d1c39
commit 7a3388646b
18 changed files with 320 additions and 72 deletions

View File

@@ -9,17 +9,22 @@
namespace App\Export;
use App\Repository\Query\ExportQuery;
final class ServiceExport
{
/**
* @var ExportRendererInterface[]
*/
private $renderer = [];
/**
* @var TimesheetExportInterface[]
*/
private $exporter = [];
/**
* @var ExportRepositoryInterface[]
*/
private $repositories = [];
public function addRenderer(ExportRendererInterface $renderer): ServiceExport
{
@@ -72,4 +77,29 @@ final class ServiceExport
return null;
}
public function addExportRepository(ExportRepositoryInterface $repository): ServiceExport
{
$this->repositories[] = $repository;
return $this;
}
public function getExportItems(ExportQuery $query)
{
$items = [];
foreach ($this->repositories as $repository) {
$items = array_merge($items, $repository->getExportItemsForQuery($query));
}
return $items;
}
public function setExported(array $items): void
{
foreach ($this->repositories as $repository) {
$repository->setExported($items);
}
}
}