MNT Use null safe operator and default to 1 page

This commit is contained in:
Michal Kleiner 2023-02-20 22:40:16 +13:00
parent 86f889b938
commit 725497a485

View File

@ -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;
}
/**