-
Notifications
You must be signed in to change notification settings - Fork 35
PSR-7 UploadedFile compatibility for RenameUpload filter #70
PSR-7 UploadedFile compatibility for RenameUpload filter #70
Conversation
I am now wondering if this filter should return a new instance of UploadedFile at https://github.com/zendframework/zend-filter/pull/70/files#diff-7218516065f9379b209dac8a0b351324R205. I think this was the original reason I had Diactoros as suggestion and I remembered it now that I have a problem with filter and validator chain. Problem with having this in a validator or filter chain is if follow up filters also want to do something with the file (eg, validate uploaded excel file has needed columns), However, downside there are some problems:
Will make another commit on this to see what you think, and because my system wont work otherwise. |
- can still be used in request handlers or other validators in the chain - reading off what new filename was generated by the filter options.
7a61c9d
to
c754d6c
Compare
File filters are a minority use case of the component, and adding a dependency on psr/http-message and zendframework/zend-diactoros is overkill if you are not using them. As such, I have made psr/http-message-implementation a suggested dependency, and zendframework/zend-diactoros a development dependency. I have also allowed either the 1.X or 2.X series of Diactoros, as they both fulfill PSR-7. Finally, to allow tests to run against 5.6 and 7.0, I have added Diactoros as a legacy dependency (so that the 1.X version can be installed), as well as zend-crypt (but only against 5.6; so that paragonie/random_compat can receive a version compatible with PHP 5).
d34597b
to
975abde
Compare
This allows testing the interactions, which means we do not need to worry about implementation.
f90bd35
to
4469b7c
Compare
First, the only development requirement when testing is now psr/http-factory (which also brings in psr/http-message). Diactoros is no longer required. However, PSR-17 requires PHP 7 and up. As such: - we cannot run the integration test in PHP versions prior to 7. - we have to remove psr/http-factory in build environments less than PHP 7. This must be done PRIOR to any installation attempts.
4469b7c
to
9bb94dd
Compare
This patch extracts the logic specific to filtering a PSR-7 `UploadedFileInterface` instance to its own method, `filterPsr7UploadedFile()`. `filter()` now detects `UploadedFileInterface` instances early in the method, and, when found, returns the return value of the new method. This keeps the logic within `filter()` simpler, and ensures all logic related to filtering PSR-7 artifacts is in one place.
…name This patch extracts two methods from the `filter()` method, `filterStringFilename()` and `filterSapiUploadedFile()`. These allow us to check for the specific conditions that we can accommodate, and then perform logic specific to each scenario. This will simplify future maintenance.
Should be just `stream_factory`, not `stream_file_factory`.
Since we have discrete conditionals for each `$value` type we can accept, we can omit the initial conditional.
This filter is a dependency for PSR-7 input filter and form validation of file fields, and acts as a prerequisite for:
Users will filter file inputs as before, using
FileNameUpload
.