After adding this module to a fresh installation of Silverstripe CMS 4.13, and not adding any specific configuration, accessing /admin/search-service/ gives the following error:
Uncaught LogicException: GridField doesn't have a modelClassName, so it doesn't know the columns of this grid.
This is because buildIndexedDocumentsList() doesn't add anything to the list if there are no indexed, which means the ArrayList doesn't ever set its data class.
Possible Solutions
Option 1
This is the most straight forward: Call $list->setDataClass(IndexedDocumentsResult::class); on the empty ArrayList as soon as it's created. That way, whether there are any indexes configured or not, the user won't get an unhelpful error.
Option 2
If the list is empty, throw a meaningful exception indicating that no indexes have been configured. This is a little less straight forward because you have to decide on the exact wording, but it does make it a lot clearer that the developer needs to perform some action.
Option 3
I don't recommend this solution, but it is one of the options available so I'll mention it anyway.
If there are no indexes configured, hide the Search Service admin altogether.
After adding this module to a fresh installation of Silverstripe CMS 4.13, and not adding any specific configuration, accessing
/admin/search-service/
gives the following error:This is because
buildIndexedDocumentsList()
doesn't add anything to the list if there are no indexed, which means theArrayList
doesn't ever set its data class.Possible Solutions
Option 1
This is the most straight forward: Call
$list->setDataClass(IndexedDocumentsResult::class);
on the emptyArrayList
as soon as it's created. That way, whether there are any indexes configured or not, the user won't get an unhelpful error.Option 2
If the list is empty, throw a meaningful exception indicating that no indexes have been configured. This is a little less straight forward because you have to decide on the exact wording, but it does make it a lot clearer that the developer needs to perform some action.
Option 3
I don't recommend this solution, but it is one of the options available so I'll mention it anyway. If there are no indexes configured, hide the Search Service admin altogether.