-
-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filesystem Extender and Tests #2732
Conversation
I think I'd prefer |
For mapping disks to drivers, we could support both: first check settings, then config.php, and if none have a value, default to |
That works too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we are extending the Laravel filesystem manager only to return a Flysystem Filesystem afterwards (see DriverInterface).
Other than that experience will tell whether this helps and callables might be hard to use as they don't have type hinting, but that was pointed out by @clarkwinkelmann in the past as well.
$config = $this->app->make(Config::class); | ||
$settings = $this->app->make(SettingsRepositoryInterface::class); | ||
|
||
$key = "disk_driver.$name"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike disk_driver
it strokes against the Laravel naming convention and the manager elsewhere uses filesystems
too. Can we use filesystem
or the plural version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Laravel config approach, there is an array of "disks", with each "disk" having a "driver" field. In this particular place, that is not inaccurate.
We could replace the 'flarum.filesystem.drivers'
binding key with 'flarum.filesystem.filesystems'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree that disk_driver
is more appropriate here.
We are extending (and overriding) the filesystem manager so that we have control over:
That being said, I think you have a good point that it's a bit odd that the output is a Flysystem interface. I did this because the vast majority of drivers will probably use flysystem so we might as well wrap in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good!
Just have a few minor nitpicks.
[ci skip] [skip ci]
[ci skip] [skip ci]
[ci skip] [skip ci]
[ci skip] [skip ci]
This gives Flarum much more flexibility in configuring filesystem disks and drivers, enabling the upcoming FIlesystem extender.
[ci skip] [skip ci]
[ci skip] [skip ci]
[ci skip] [skip ci]
[ci skip] [skip ci]
5a49cbf
to
32d0634
Compare
Followup to #2729
Part of #1783
Part of flarum/issue-archive#121
Changes proposed in this pull request:
Currently, drivers for disks are determined via the following process:
disk_driver.${DISK_NAME}
setting key exists, proceed to step 2. Else return'local'
'local'
This gives us safety in case the extension providing the filesystem driver being used is removed.
This PR does not attempt to introduce a UI for:
We might want to eventually add that though.
Reviewers should focus on:
Do we want to use
config.php
or settings? Right now, this PR selects the driver for each disk from settings. It passes both settings and config to drivers, so they can choose which they prefer. Should we also support setting drivers for disks in config?I also put together a proof of concept extension for Azure at https://github.com/askvortsov1/flarum-azure-poc.
Confirmed
composer test
).