diff --git a/Controller/UploadController.php b/Controller/UploadController.php index cfcc654af8381e9bf34b8fd0252329e720935e49..7c32e3240893d28005fe00ece78bc337d8fdb4fd 100644 --- a/Controller/UploadController.php +++ b/Controller/UploadController.php @@ -10,6 +10,7 @@ namespace Irstea\FileUploadBundle\Controller; use Irstea\FileUploadBundle\Entity\UploadedFile; use Irstea\FileUploadBundle\Http\UploadedFileResponse; use Irstea\FileUploadBundle\Model\FileManagerInterface; +use Irstea\FileUploadBundle\Model\UploadedFileInterface; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -77,18 +78,20 @@ class UploadController extends Controller $deleteUrl = $this->router->generate('file_upload_delete', $parameters); - return $this->createResponse( - Response::HTTP_CREATED, - 'New file created', - [ - 'id' => $file->getId(), - 'put_url' => $this->router->generate('file_upload_put_content', $parameters), - 'delete_type' => 'DELETE', - 'delete_url' => $deleteUrl, - ], - // On a pas de get pour l'instant, le DELETE et ce qui y ressemble le plus - [ 'Location' => $deleteUrl ] - ); + return $this->createResponse( + Response::HTTP_CREATED, + 'New file created', + array_merge( + $file->toArray(), + [ + 'put_url' => $this->router->generate('file_upload_put_content', $parameters), + 'delete_type' => 'DELETE', + 'delete_url' => $deleteUrl + ] + ), + // On a pas de get pour l'instant, le DELETE et ce qui y ressemble le plus + [ 'Location' => $deleteUrl ] + ); } /** @@ -142,16 +145,14 @@ class UploadController extends Controller 'File uploaded', [ 'files' => [ - [ - 'id' => $file->getId(), - 'name' => $file->getDisplayName(), - 'type' => $file->getMimeType(), - 'size' => $file->getSize(), - 'icon' => MimeTypeIcon::getMimeTypeIcon($file->getMimeType()), - 'url' => $this->router->generate('file_upload_get_content', $parameters), - 'delete_type' => 'DELETE', - 'delete_url' => $this->router->generate('file_upload_delete', $parameters), - ] + array_merge( + $file->toArray(), + [ + 'url' => $this->router->generate('file_upload_get_content', $parameters), + 'delete_type' => 'DELETE', + 'delete_url' => $this->router->generate('file_upload_delete', $parameters), + ] + ) ] ] );