-
Notifications
You must be signed in to change notification settings - Fork 50
Add file input compatibility with PSR-7 #172
Add file input compatibility with PSR-7 #172
Conversation
Looks like Travis does not like to pull from other repositories not having its own tokens. |
@alextech you can insert "repositories": [
{
"type": "vcs",
"url": "https://github.com/alextech/zend-validator",
"no-api": true
},
{
"type": "vcs",
"url": "https://github.com/alextech/zend-filter",
"no-api": true
}
], |
4367708
to
e6d013a
Compare
…e instead of $_FILES. Using own repository for zend-validator for tests to pass, as filter has tight dependency on validator.
…ate a bridge to appropriate PSR or HTTP filter implementation. Change to decorator style and move detection of value type to public facing FileInput.
…the FileInput entry point does this already.
- PSR-7 becomes optional; only required if validating PSR-7 `UploadedFileInterface` instances. - Diactoros is no longer required for testing; we can mock PSR-7 interface.
fe04190
to
1baf31f
Compare
This patch moves the new file input decorators to the namespace `Zend\InputFilter\FileInput`, and performs a number of minor refactors on them to improve readability. Tests are refactored slightly to use generators where appropriate, and to mock PSR-7 interfaces instead of using Diactoros.
Adds a section to the file input chapter covering PSR-7, and showing how to get the merged form and uploaded file data to pass to the input filter.
1baf31f
to
3b32a72
Compare
@alextech I've rebased off of current develop, and done the following:
I think it should be ready to 🚢 now. |
*/ | ||
protected function injectUploadValidator() |
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.
removing protected
methods isn't BC break?
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.
This method is protected
;-) Only changes to public interface are considered as BC Break.
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.
sorry I mean protected
:) and I thought that if you set method protected
it's like saying that you are safe to extend it if you need and we will not change it.
I thought protected classifies as BC break too, because class open to
extension will break if being extended and signature changes between
upgrades.
вт, 18 дек. 2018 г., 2:39 Michał Bundyra notifications@github.com:
… ***@***.**** commented on this pull request.
------------------------------
In src/FileInput.php
<#172 (comment)>
:
> */
- protected function injectUploadValidator()
This method is protected ;-) Only changes to *public* interface are
considered as BC Break.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#172 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADpNHETXLNphWTnQ8Zx0tKt1WoXocb_Rks5u6JvEgaJpZM4WAsfF>
.
|
@alextech As far as I know (if I am wrong please someone correct me) - in ZF rules for public interface are "public" methods and "protected" only when these are described as can be used in extension (for example in the documentation). I don't remember where I read about it, I can't find it now :( |
@svycka @alextech and @webimpress — Our policy since the ZF1 days has been to treat only In this particular case, there's little reason for extension, and the new changes make creating new strategies for file uploads easier. |
@weierophinney I am ok with this change just maybe this should be noted in changelog. |
Like zendframework/zend-filter#70 this PR introduced a BC Break. Hope to isolate the issue and post a PR soon. |
Fixes #145 - PSR-7 compatibility for validating and filtering forms with inputs.
This patch allows validating forms submitted via a PSR-7 payload, and, specifically file uploads.
Prerequisite PRs:
I could not separate PSR vs HTTP $_FilES into completely separate subclasses because current implementation is stateful, so cannot simply pass calls from current
FileInput
to appropriate implementation - private protected properties that hold values and options get lost.FileInput
is hardcoded in other repositories, egZend\Form
as a input specification so has to remain main entry point for forms to be used in both MVC and Expressive. Consequently, did decorator-ish style approach.