We are returning a ModifiedResourceResponse rather than the ResourceResponse documented here. Let's use ResourceResponseInterface which covers both.
ModifiedResourceResponse
ResourceResponse
ResourceResponseInterface
Now we are throwing an error if the element does not exist, but what if this is not a file element but something else like a text field? Maybe we can do a more exhaustive check.
We are returning a
ModifiedResourceResponse
rather than theResourceResponse
documented here. Let's useResourceResponseInterface
which covers both.