FIX Handle null returns in GridFieldDetailForm_ItemRequest::getNumPages()

This commit is contained in:
Steve Boyd 2023-02-20 14:37:48 +13:00
parent bf058ee968
commit e455aa5c5e

View File

@ -665,11 +665,18 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
*/ */
private function getNumPages(GridField $gridField): int private function getNumPages(GridField $gridField): int
{ {
return $gridField /** @var GridFieldPaginator $component */
$component = $gridField
->getConfig() ->getConfig()
->getComponentByType(GridFieldPaginator::class) ->getComponentByType(GridFieldPaginator::class);
->getTemplateParameters($gridField) if (is_null($component)) {
->toMap()['NumPages']; return 1;
}
$params = $component->getTemplateParameters($gridField);
if (is_null($params)) {
return 1;
}
return $params->toMap()['NumPages'];
} }
/** /**