Added fix to allow nested AutoDatasource instances to manage their own populateCache

This commit is contained in:
Jack Wilkinson 2022-12-08 18:08:59 +00:00
parent 4f0da6cd0c
commit 5540dadaaf

View File

@ -68,6 +68,14 @@ class AutoDatasource extends Datasource implements DatasourceInterface
$this->postProcessor = new Processor;
}
/**
* Returns the in memory path cache map
*/
public function getPathCache(): array
{
return $this->pathCache;
}
/**
* Populate the local cache of paths available in each datasource
*
@ -78,6 +86,13 @@ class AutoDatasource extends Datasource implements DatasourceInterface
{
$pathCache = [];
foreach ($this->datasources as $datasource) {
// Allow AutoDatasource instances to handle their own internal caching
if ($datasource instanceof AutoDatasource) {
$datasource->populateCache($refresh);
$pathCache[] = array_merge(...array_reverse($datasource->getPathCache()));
continue;
}
// Remove any existing cache data
if ($refresh && $this->allowCacheRefreshes) {
Cache::forget($datasource->getPathsCacheKey());