Skip to content

Commit

Permalink
Make drivers opt-in, rather than opt-out (#268)
Browse files Browse the repository at this point in the history
* Eloquent driver should be opt-in, not opt-out

* Swap all drivers to `eloquent` in our `TestCase`
  • Loading branch information
duncanmcclean authored Apr 10, 2024
1 parent ee259e8 commit 3c23d60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 15 additions & 15 deletions config/eloquent-driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,84 @@
'table_prefix' => env('STATAMIC_ELOQUENT_PREFIX', ''),

'asset_containers' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Assets\AssetContainerModel::class,
],

'assets' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Assets\AssetModel::class,
'asset' => \Statamic\Eloquent\Assets\Asset::class,
],

'blueprints' => [
'driver' => 'eloquent',
'driver' => 'file',
'blueprint_model' => \Statamic\Eloquent\Fields\BlueprintModel::class,
'fieldset_model' => \Statamic\Eloquent\Fields\FieldsetModel::class,
],

'collections' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Collections\CollectionModel::class,
'update_entry_order_queue' => 'default',
'update_entry_order_connection' => 'default',
],

'collection_trees' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Structures\TreeModel::class,
'tree' => \Statamic\Eloquent\Structures\CollectionTree::class,
],

'entries' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Entries\EntryModel::class,
'entry' => \Statamic\Eloquent\Entries\Entry::class,
],

'forms' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Forms\FormModel::class,
],

'form_submissions' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Forms\SubmissionModel::class,
],

'global_sets' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Globals\GlobalSetModel::class,
],

'global_set_variables' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Globals\VariablesModel::class,
],

'navigations' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Structures\NavModel::class,
],

'navigation_trees' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Structures\TreeModel::class,
'tree' => \Statamic\Eloquent\Structures\NavTree::class,
],

'revisions' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Revisions\RevisionModel::class,
],

'taxonomies' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Taxonomies\TaxonomyModel::class,
],

'terms' => [
'driver' => 'eloquent',
'driver' => 'file',
'model' => \Statamic\Eloquent\Taxonomies\TermModel::class,
],
];
4 changes: 4 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ protected function resolveApplicationConfiguration($app)
parent::resolveApplicationConfiguration($app);

$app['config']->set('statamic.eloquent-driver', require (__DIR__.'/../config/eloquent-driver.php'));

collect(config('statamic.eloquent-driver'))
->filter(fn ($config) => isset($config['driver']))
->each(fn ($config, $key) => $app['config']->set("statamic.eloquent-driver.{$key}.driver", 'eloquent'));
}

protected function getEnvironmentSetUp($app)
Expand Down

0 comments on commit 3c23d60

Please sign in to comment.