mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Use null safe operator and default to 1 page
This commit is contained in:
parent
86f889b938
commit
725497a485
@ -665,18 +665,11 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
*/
|
||||
private function getNumPages(GridField $gridField): int
|
||||
{
|
||||
/** @var GridFieldPaginator $component */
|
||||
$component = $gridField
|
||||
->getConfig()
|
||||
->getComponentByType(GridFieldPaginator::class);
|
||||
if (is_null($component)) {
|
||||
return 1;
|
||||
}
|
||||
$params = $component->getTemplateParameters($gridField);
|
||||
if (is_null($params)) {
|
||||
return 1;
|
||||
}
|
||||
return $params->toMap()['NumPages'];
|
||||
return $gridField
|
||||
->getConfig()
|
||||
->getComponentByType(GridFieldPaginator::class)
|
||||
?->getTemplateParameters($gridField)
|
||||
?->toMap()['NumPages'] ?? 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user