@@ -42,6 +42,7 @@ abstract class AbstractListView
4242 private bool $ allowFiltering = true ;
4343 private bool $ allowSorting = true ;
4444 private bool $ allowInteractions = true ;
45+ private int $ maxItems = 0 ;
4546
4647 /**
4748 * @var array<string, string>
@@ -84,6 +85,22 @@ public function setItemsPerPage(int $itemsPerPage): void
8485 $ this ->itemsPerPage = $ itemsPerPage ;
8586 }
8687
88+ /**
89+ * Gets the maximum number of items shown.
90+ */
91+ public function getMaxItems (): int
92+ {
93+ return $ this ->maxItems ;
94+ }
95+
96+ /**
97+ * Sets the maximum number of items shown.
98+ */
99+ public function setMaxItems (int $ maxItems ): void
100+ {
101+ $ this ->maxItems = $ maxItems ;
102+ }
103+
87104 /**
88105 * Sets the sort field of the list view.
89106 */
@@ -182,8 +199,10 @@ public function getBaseUrl(): string
182199 protected function initObjectList (): void
183200 {
184201 $ this ->objectList = $ this ->createObjectList ();
185- $ this ->objectList ->sqlLimit = $ this ->getItemsPerPage ();
186- $ this ->objectList ->sqlOffset = ($ this ->getPageNo () - 1 ) * $ this ->getItemsPerPage ();
202+ $ this ->objectList ->sqlLimit = $ this ->getMaxItems () ?: $ this ->getItemsPerPage ();
203+ if (!$ this ->getMaxItems ()) {
204+ $ this ->objectList ->sqlOffset = ($ this ->getPageNo () - 1 ) * $ this ->getItemsPerPage ();
205+ }
187206 if ($ this ->getSortField ()) {
188207 $ sortFieldObject = $ this ->availableSortFields [$ this ->getSortField ()];
189208
@@ -243,6 +262,9 @@ public function countItems(): int
243262 {
244263 if (!isset ($ this ->objectCount )) {
245264 $ this ->objectCount = $ this ->getObjectList ()->countObjects ();
265+ if ($ this ->getMaxItems () && $ this ->getMaxItems () < $ this ->objectCount ) {
266+ $ this ->objectCount = $ this ->getMaxItems ();
267+ }
246268 }
247269
248270 return $ this ->objectCount ;
0 commit comments