Skip to content

Commit

Permalink
Don't nest AutoDatasources inside of other AutoDatasources.
Browse files Browse the repository at this point in the history
Refs / requires: wintercms/winter@cfb8cdf
  • Loading branch information
LukeTowers committed Sep 27, 2023
1 parent f94479a commit 4e8dfa9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,17 @@ protected function extendThemeDatasource(): void
// Register the block manager instance
BlockManager::instance();
Event::listen('cms.theme.registerHalcyonDatasource', function (Theme $theme, $resolver) {
$resolver->addDatasource($theme->getDirName(), new AutoDatasource([
'theme' => $theme->getDatasource(),
'blocks' => new BlocksDatasource(),
], 'blocks-autodatasource'));
$source = $theme->getDatasource();
if ($source instanceof AutoDatasource) {
/* @var AutoDatasource $source */
$source->appendDatasource('blocks', new BlocksDatasource());
return;
} else {
$resolver->addDatasource($theme->getDirName(), new AutoDatasource([
'theme' => $source,
'blocks' => new BlocksDatasource(),
], 'blocks-autodatasource'));
}
});
}

Expand Down

0 comments on commit 4e8dfa9

Please sign in to comment.