dustin10/VichUploaderBundle — pull request #304 by ftassi (2014-09-05 08:16:01+00:00)
Title: Fix file injector

I've spotted some issue with file injector.

First of all the test was wrong, the mock defined a method which does not exists in the concrete class (if I'm not wrong) and more important, the behaviour seems not correct to me.

If $path is null the file should not be injected, as I wrote in 9479e0e
I'm also not getting why we're catching for InvalidArgumentException. The try...catch has been introduced by 61ae3376 but it make no sense to me. Why the injector should catch an InvalidArgumentException and silently fail to inject to file into the object?

If we want to use an exception to control that flow, it can't be InvalidArgumentException, it has to be something more meaningful, and it has to be documented in \Vich\UploaderBundle\Storage\StorageInterface

As for me a null $path make perfect sense for a non existing file and I think we could simply:
* Do no inject the file if path is null
* Remove the try...catch block.

I kept it because I'm not sure if some other StorageInterface implementations actually throws it when the file is not present (if so we should fix them).