Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -9,6 +9,7 @@
namespace App\Export;
use App\Entity\ExportableItem;
use App\Event\ExportItemsQueryEvent;
use App\Repository\Query\ExportQuery;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
@@ -27,14 +28,9 @@ final class ServiceExport
* @var ExportRepositoryInterface[]
*/
private $repositories = [];
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
public function __construct(EventDispatcherInterface $eventDispatcher)
public function __construct(private EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
public function addRenderer(ExportRendererInterface $renderer): void
@@ -92,19 +88,17 @@ final class ServiceExport
/**
* @param ExportQuery $query
* @return ExportItemInterface[]
* @return ExportableItem[]
* @throws TooManyItemsExportException
*/
public function getExportItems(ExportQuery $query)
public function getExportItems(ExportQuery $query): array
{
$items = [];
$event = new ExportItemsQueryEvent($query);
$this->eventDispatcher->dispatch($event);
$max = $event->getExportQuery()->getMaxResults();
$max = $this->getMaximumResults($query);
foreach ($this->repositories as $repository) {
$items = array_merge($items, $repository->getExportItemsForQuery($event->getExportQuery()));
$items = array_merge($items, $repository->getExportItemsForQuery($query));
if ($max !== null && \count($items) > $max) {
throw new TooManyItemsExportException(
sprintf('Limit reached! Expected max. %s items but got %s', $max, \count($items))
@@ -121,4 +115,12 @@ final class ServiceExport
$repository->setExported($items);
}
}
public function getMaximumResults(ExportQuery $query): ?int
{
$event = new ExportItemsQueryEvent($query);
$this->eventDispatcher->dispatch($event);
return $event->getExportQuery()->getMaxResults();
}
}