Closed Firesphere closed 7 years ago
Yeah — use a namespace and use PSR-4 class loader.
Before namespacing your code you may want to talk to TSP about whether this will be our officially supported module (which would make sense); in which case the package name might be silverstripe/s3assets
and the namespace SilverStripe\S3Assets
It'd be better to have all the getenv('SS_AWS_S3_KEY') checks in a _config.php
I think it would be better still to use the backtick syntax in config yaml, using these variables to configure a default Injector service. Maybe ask @tractorcow for if/how this works.
At https://github.com/madmatt/silverstripe-s3/blob/master/src/SilverStripeS3AdapterTrait.php#L4, why is it not namespaced? Any specific reason?
Ah, because it was previously in a single file that was namespaced, and I copied it out into it's own file and forgot the namespace declaration. Fixed in 0.2.0.
Dockblocks are missing
I've added a couple, I'm not sure about re-working the trait yet so haven't documented that as I expect it will change.
It'd be better to have all the getenv('SS_AWS_S3_KEY') checks in a _config.php, breaking out of functioning when it's not set, instead of checking it every time in the Trait
The way it currently works is a bit more performant because doing it in _config.php means that it will get executed on every request (whereas now it only gets called when an asset is actually required - e.g. it's not even used when accessing /admin/assets, just when calling the graphql endpoint to get data).
However I'd like a better way to specify this too so it doesn't need a whole trait just for configuration. I'll have a think.
Oops, didn't mean to close this. Thanks for the comments @Firesphere and @sminnee.
Hmmm, not checking in _config.php actually makes sense. I'm off to YubiAuth to fix this!
With the repository move I'll close this for now, the only remaining thing was where the getenv()
calls live, which I'm okay with living in the adapter rather than _config for now.