Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Apr 22, 2021
2 parents 9350386 + a8731dc commit e6976f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Admin/AbstractAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ abstract class AbstractAdmin extends AbstractTaggedAdmin implements AdminInterfa
private const MASK_OF_ACTION_LIST = self::ACTION_SHOW | self::ACTION_EDIT | self::ACTION_DELETE | self::ACTION_ACL | self::ACTION_BATCH;
private const MASK_OF_ACTIONS_USING_OBJECT = self::MASK_OF_ACTION_SHOW | self::MASK_OF_ACTION_EDIT | self::MASK_OF_ACTION_HISTORY | self::MASK_OF_ACTION_ACL;

private const DEFAULT_LIST_PER_PAGE_RESULTS = 25;
private const DEFAULT_LIST_PER_PAGE_OPTIONS = [10, 25, 50, 100, 250];

/**
* The list FieldDescription constructed from the configureListField method.
*
Expand Down Expand Up @@ -1032,7 +1035,7 @@ final public function getMaxPerPage(): int
{
$sortValues = $this->getDefaultSortValues();

return $sortValues[DatagridInterface::PER_PAGE] ?? 25;
return $sortValues[DatagridInterface::PER_PAGE] ?? self::DEFAULT_LIST_PER_PAGE_RESULTS;
}

final public function setMaxPageLinks(int $maxPageLinks): void
Expand Down Expand Up @@ -1680,7 +1683,7 @@ final public function supportsPreviewMode(): bool
*/
public function getPerPageOptions(): array
{
$perPageOptions = [10, 25, 50, 100, 250];
$perPageOptions = self::DEFAULT_LIST_PER_PAGE_OPTIONS;
$perPageOptions[] = $this->getMaxPerPage();

$perPageOptions = array_unique($perPageOptions);
Expand Down Expand Up @@ -2045,7 +2048,7 @@ protected function configureFilterParameters(array $parameters): array
*/
final protected function getDefaultSortValues(): array
{
$defaultSortValues = [DatagridInterface::PAGE => 1, DatagridInterface::PER_PAGE => 25];
$defaultSortValues = [DatagridInterface::PAGE => 1, DatagridInterface::PER_PAGE => self::DEFAULT_LIST_PER_PAGE_RESULTS];

$this->configureDefaultSortValues($defaultSortValues);

Expand Down
4 changes: 2 additions & 2 deletions tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1508,8 +1508,8 @@ public function testGetFilterParametersWithoutRequest(): void

$parameters = $commentAdmin->getFilterParameters();

$this->assertArrayHasKey('_per_page', $parameters);
$this->assertSame(25, $parameters['_per_page']);
$this->assertArrayHasKey(DatagridInterface::PER_PAGE, $parameters);
$this->assertSame(25, $parameters[DatagridInterface::PER_PAGE]);
}

public function testGetFilterFieldDescription(): void
Expand Down

0 comments on commit e6976f2

Please sign in to comment.