table.php: add possibility to set pageSize
diff --git a/blocks/bacluc_event_block/controller.php b/blocks/bacluc_event_block/controller.php
index d68152c..01c90da 100755
--- a/blocks/bacluc_event_block/controller.php
+++ b/blocks/bacluc_event_block/controller.php
@@ -150,7 +150,7 @@
private function processAction(ActionProcessor $actionProcessor, ...$additionalParams)
{
- return $actionProcessor->process($this->request->get(null) ?: [],
+ return $actionProcessor->process($this->request->query->all() ?: [],
$this->request->post(null) ?: [],
array_key_exists(0, $additionalParams) ? $additionalParams[0] : null);
}
diff --git a/blocks/bacluc_next_event_block/controller.php b/blocks/bacluc_next_event_block/controller.php
index 6b4fe7b..c662f8f 100755
--- a/blocks/bacluc_next_event_block/controller.php
+++ b/blocks/bacluc_next_event_block/controller.php
@@ -76,7 +76,7 @@
private function processAction(ActionProcessor $actionProcessor, ...$additionalParams)
{
- return $actionProcessor->process($this->request->get(null) ?: [],
+ return $actionProcessor->process($this->request->query->all() ?: [],
$this->request->post(null) ?: [],
array_key_exists(0, $additionalParams) ? $additionalParams[0] : null);
}
diff --git a/src/CancellationsRepository.php b/src/CancellationsRepository.php
index 59a0a06..f8ebd10 100644
--- a/src/CancellationsRepository.php
+++ b/src/CancellationsRepository.php
@@ -58,13 +58,15 @@
return $this->standardRepository->delete($toDeleteEntity);
}
- public function getCancellationsOfEvent(int $eventId)
+ public function getCancellationsOfEvent(int $eventId, int $offset, int $limit)
{
$qb = $this->entityManager->createQueryBuilder();
$qb->select('cancellation')
->from(EventCancellation::class, "cancellation")
->join("cancellation.event", "event")
->where($qb->expr()->eq("event.id", ":eventId"))
+ ->setFirstResult($offset)
+ ->setMaxResults($limit)
->orderBy('cancellation.name')
->setParameter("eventId", $eventId);
$query = $qb->getQuery();
diff --git a/src/EventCancellationsTableEntrySupplier.php b/src/EventCancellationsTableEntrySupplier.php
index 7870614..c90f875 100644
--- a/src/EventCancellationsTableEntrySupplier.php
+++ b/src/EventCancellationsTableEntrySupplier.php
@@ -4,6 +4,7 @@
namespace BaclucEventPackage;
+use BaclucC5Crud\Controller\PaginationConfiguration;
use BaclucC5Crud\Entity\TableViewEntrySupplier;
class EventCancellationsTableEntrySupplier implements TableViewEntrySupplier
@@ -24,9 +25,11 @@
}
- public function getEntries()
+ public function getEntries(PaginationConfiguration $paginationConfiguration)
{
- return $this->cancellationsRepository->getCancellationsOfEvent($this->eventId);
+ return $this->cancellationsRepository->getCancellationsOfEvent($this->eventId,
+ $paginationConfiguration->getOffset(),
+ $paginationConfiguration->getPageSize());
}
public function count()
diff --git a/src/NextEvent/ShowNextEvent.php b/src/NextEvent/ShowNextEvent.php
index e7ab462..9589cac 100644
--- a/src/NextEvent/ShowNextEvent.php
+++ b/src/NextEvent/ShowNextEvent.php
@@ -4,6 +4,7 @@
namespace BaclucEventPackage\NextEvent;
+use BaclucC5Crud\Controller\PaginationConfiguration;
use BaclucC5Crud\Controller\Renderer;
use BaclucC5Crud\Controller\VariableSetter;
use BaclucC5Crud\TableViewService;
@@ -57,7 +58,7 @@
function process(array $get, array $post, ...$additionalParameters)
{
- $tableView = $this->tableViewService->getTableView();
+ $tableView = $this->tableViewService->getTableView(new PaginationConfiguration(0, null));
$rows = $tableView->getRows();
if (sizeof($rows) >= 1) {
diff --git a/src/NextEvent/ShowNextEventEntrySupplier.php b/src/NextEvent/ShowNextEventEntrySupplier.php
index b4ffce5..76998d3 100644
--- a/src/NextEvent/ShowNextEventEntrySupplier.php
+++ b/src/NextEvent/ShowNextEventEntrySupplier.php
@@ -4,6 +4,7 @@
namespace BaclucEventPackage\NextEvent;
+use BaclucC5Crud\Controller\PaginationConfiguration;
use BaclucC5Crud\Entity\ConfigurationSupplier;
use BaclucC5Crud\Entity\TableViewEntrySupplier;
use BaclucEventPackage\EventRepository;
@@ -27,7 +28,7 @@
$this->configurationSupplier = $configurationSupplier;
}
- public function getEntries()
+ public function getEntries(PaginationConfiguration $paginationConfiguration)
{
/** @var NextEventConfiguration $configuration */
$configuration = $this->configurationSupplier->getConfiguration();
diff --git a/src/ShowCancellations.php b/src/ShowCancellations.php
index 9adc66f..2094a88 100644
--- a/src/ShowCancellations.php
+++ b/src/ShowCancellations.php
@@ -6,9 +6,11 @@
use BaclucC5Crud\Controller\ActionProcessor;
use BaclucC5Crud\Controller\ActionRegistryFactory;
+use BaclucC5Crud\Controller\PaginationParser;
use BaclucC5Crud\Controller\Renderer;
use BaclucC5Crud\Controller\VariableSetter;
use BaclucC5Crud\TableViewService;
+use BaclucC5Crud\View\FormView\IntegerField;
use BaclucC5Crud\View\TableView\TableViewFieldConfiguration;
use BaclucC5Crud\View\ViewActionRegistry;
@@ -39,6 +41,10 @@
* @var ViewActionRegistry
*/
private $viewActionRegistry;
+ /**
+ * @var PaginationParser
+ */
+ private $paginationParser;
public function __construct(
VariableSetter $variableSetter,
@@ -46,7 +52,8 @@
NoEditIdFallbackActionProcessor $noEditIdFallbackActionProcessor,
TableViewFieldConfiguration $tableViewFieldConfiguration,
CancellationsRepository $cancellationsRepository,
- ViewActionRegistry $viewActionRegistry
+ ViewActionRegistry $viewActionRegistry,
+ PaginationParser $paginationParser
) {
$this->variableSetter = $variableSetter;
$this->renderer = $renderer;
@@ -54,6 +61,7 @@
$this->tableViewFieldConfiguration = $tableViewFieldConfiguration;
$this->cancellationsRepository = $cancellationsRepository;
$this->viewActionRegistry = $viewActionRegistry;
+ $this->paginationParser = $paginationParser;
}
function getName(): string
@@ -77,13 +85,16 @@
$tableViewService =
new TableViewService($eventCancellationsTableEntrySupplier, $this->tableViewFieldConfiguration);
- $tableView = $tableViewService->getTableView();
+ $paginationConfiguration = $this->paginationParser->parse($get);
+ $tableView = $tableViewService->getTableView($paginationConfiguration);
$this->variableSetter->set("headers", $tableView->getHeaders());
$this->variableSetter->set("rows", $tableView->getRows());
$this->variableSetter->set("actions",
[$this->viewActionRegistry->getByName(ActionRegistryFactory::BACK_TO_MAIN)]);
$this->variableSetter->set("rowactions", []);
$this->variableSetter->set("count", $tableView->getCount());
+ $pageSizeField = new IntegerField("Entries to display", "pageSize", $paginationConfiguration->getPageSize());
+ $this->variableSetter->set("pageSizeField", $pageSizeField);
$this->renderer->render(self::TABLE_VIEW);
}