statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 73 forks source link

Possibility to override Asset class like possible with Entries via config file #131

Closed lukeptchr closed 1 year ago

lukeptchr commented 1 year ago

I came to a situation where I need to override the shallowAugmentedArrayKeys of the Asset. But there is no possibility to override the Asset class.

This is possible for Entries in eloquent-driver.php config file -> entries.entry.

So I suggest to add assets.asset in eloquent-driver.php .

And then change Statamic\Eloquent\Assets\AssetRepository from AssetContract::class => Asset::class,

To AssetContract::class => config('statamic.eloquent-driver.assets.asset'),

ryanmitchell commented 1 year ago

You can bind your own Asset class to the contract in your service provider, but yes that could definitely be made simpler with a config.

You could PR the config, then bind it like we do for entries: https://github.com/statamic/eloquent-driver/blob/master/src/ServiceProvider.php#L181-L183

Then use that bound value in the AssetRepository.

lukeptchr commented 1 year ago

Yes I have the PR already ready locally. But this will be a breaking change since this will require the config file change.

ryanmitchell commented 1 year ago

It wouldnt be a breaking change if you specify the current default when using config() ?

lukeptchr commented 1 year ago

Of course, smart move!

ryanmitchell commented 1 year ago

Are you still planning on opening a PR for this @lukeptchr ?

ryanmitchell commented 1 year ago

I've opened a PR for this over here

lukevmk commented 1 year ago

I'm sorry, I just saw this. Thanks for opening the PR!