Open jakejohns opened 7 years ago
Ugh -- you're right.
Is there perhaps some way to cast the UploadedFile objects back to arrays, or even StdClass objects, so that they match $_FILES more closely? Then at least you don't have to typehint (though you do need to know the structure of the array or object).
What is the domain expecting as input in a case like this? Isn't the whole notion of UploadFile
a very HTTP (and $_FILES
) oriented concept? Is the domain expecting a file path for a file it can open and manipulate? Something else? It seems to me that maybe the Input
handler is the right place to do the conversion -- although avoiding any exception throwing operations might be difficult in some cases.
The default
Input
class does this:I think there's a problem here because
$request->getUploadedFiles()
will return an array ofUploadedFileInterface
and it does not seem correct to be relying-on/using/type-hinting/etc such a class inside my domain. The PSR7 interfaces are for HTTP and thereby define the UI. I would think that theInput
class is the boundary over which such details do not pass.It would be silly to write a CLI interface for my domain and require
psr/http-message
so that when a file is passed at the commandline I can convert it to anUploadedFileInterface
.Here's what I basically ended up doing recently (abstracted a bit from my actual implementation):
I know the default
Input
here is just a "starting point", but I question if its wise to encourage leakingHttp\Message\*
into the domain. On the other hand, now I'm hitting the file system in myInput
handler, but somehow this seems less wrong to me?Anyone have any better ideas on this?