I am receiving an error when I try to call $this->indexInAlgolia() after creating a ‘Provider’ dataobject which is not using the versioning extension.
I have added the following method to my dataobject to manually add the object to the Algolia index when creating/updating as (I think) it said in the instructions:
public function onAfterWrite()
{
parent::onAfterWrite();
if ($this->canIndexInAlgolia()) {
$this->indexInAlgolia();
}
}
When creating a new Provider I receive the following error:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given at /var/www/localhost/htdocs/vendor/wilr/silverstripe-algolia/src/Service/AlgoliaIndexer.php:66
I can temporarily fix the error by hacking the Wilr\SilverStripe\Algolia\Service\AlgoliaIndexer indexItem() method code to check if the result is already an array (which it appears to be):
if (!is_array($fields)) {
if (method_exists($fields, 'toArray')) {
$fields = $fields->toArray();
}
}
I can't work out how I should implement this correctly to avoid the error. Are there any examples I could see, or could the docs be padded out a little to show how to do this? :) Thank you.
I am receiving an error when I try to call $this->indexInAlgolia() after creating a ‘Provider’ dataobject which is not using the versioning extension.
I have added the following method to my dataobject to manually add the object to the Algolia index when creating/updating as (I think) it said in the instructions:
When creating a new Provider I receive the following error:
method_exists(): Argument #1 ($object_or_class) must be of type object|string, array given at /var/www/localhost/htdocs/vendor/wilr/silverstripe-algolia/src/Service/AlgoliaIndexer.php:66
I can temporarily fix the error by hacking the Wilr\SilverStripe\Algolia\Service\AlgoliaIndexer indexItem() method code to check if the result is already an array (which it appears to be):
I can't work out how I should implement this correctly to avoid the error. Are there any examples I could see, or could the docs be padded out a little to show how to do this? :) Thank you.
(Also posted on the SilverStripe forum here but there were no responses.)