public function overwriteAction($anId, Request $aRequest, FileCommandBus $aCommandBus, $aProperty)
    {
        if (false === $aRequest->files->has($aProperty)) {
            throw new \InvalidArgumentException(sprintf('Given %s property is not in the request', $aProperty));
        }

        $uploadedFile = $aRequest->files->get($aProperty);
        $command = new OverwriteFileCommand(
            $anId,
            $uploadedFile->getClientOriginalName(),
            file_get_contents($uploadedFile->getPathname()),
            $uploadedFile->getMimeType()
        );
        $aCommandBus->handle($command);

        $aRequest->files->remove($aProperty);

        return [
            'id'        => $command->id(),
            'filename'  => $uploadedFile->getClientOriginalName(),
            'mime_type' => $uploadedFile->getMimeType(),
        ];
    }
public function overwriteAction($anId, Request $aRequest, FileCommandBus $aCommandBus, $aProperty)
    {
        if (false === $aRequest->files->has($aProperty)) {
            throw new \InvalidArgumentException(sprintf('Given %s property is not in the request', $aProperty));
        }

        $uploadedFile = $aRequest->files->get($aProperty);
        $command = new OverwriteFileCommand(
            $anId,
            $uploadedFile->getClientOriginalName(),
            file_get_contents($uploadedFile->getPathname()),
            $uploadedFile->getMimeType()
        );
        $aCommandBus->handle($command);

        $aRequest->files->remove($aProperty);

        return [
            'id'        => $command->id(),
            'filename'  => $uploadedFile->getClientOriginalName(),
            'mime_type' => $uploadedFile->getMimeType(),
        ];
    }
public function overwriteAction ( $ anId , Request $ aRequest , FileCommandBus $ aCommandBus , $ aProperty ) { if ( false === $ aRequest -> files -> has ( $ aProperty ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Given %s property is not in the request' , $ aProperty ) ) ; } $ uploadedFile = $ aRequest -> files -> get ( $ aProperty ) ; $ command = new OverwriteFileCommand ( $ anId , $ uploadedFile -> getClientOriginalName ( ) , file_get_contents ( $ uploadedFile -> getPathname ( ) ) , $ uploadedFile -> getMimeType ( ) ) ; $ aCommandBus -> handle ( $ command ) ; $ aRequest -> files -> remove ( $ aProperty ) ; return [ 'id' => $ command -> id ( ) , 'filename' => $ uploadedFile -> getClientOriginalName ( ) , 'mime_type' => $ uploadedFile -> getMimeType ( ) , ] ; }
Overwrite action.

@param string         $anId        The file id
@param Request        $aRequest    The request
@param FileCommandBus $aCommandBus The command bus
@param string         $aProperty   The file property that want to get from request

@return array
Overwrite action .