Commit ea4c5c64 authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

UploadController: utilise la méthode UploadedFileInterface->toArray.

Showing with 23 additions and 22 deletions
+23 -22
...@@ -10,6 +10,7 @@ namespace Irstea\FileUploadBundle\Controller; ...@@ -10,6 +10,7 @@ namespace Irstea\FileUploadBundle\Controller;
use Irstea\FileUploadBundle\Entity\UploadedFile; use Irstea\FileUploadBundle\Entity\UploadedFile;
use Irstea\FileUploadBundle\Http\UploadedFileResponse; use Irstea\FileUploadBundle\Http\UploadedFileResponse;
use Irstea\FileUploadBundle\Model\FileManagerInterface; use Irstea\FileUploadBundle\Model\FileManagerInterface;
use Irstea\FileUploadBundle\Model\UploadedFileInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
...@@ -77,18 +78,20 @@ class UploadController extends Controller ...@@ -77,18 +78,20 @@ class UploadController extends Controller
$deleteUrl = $this->router->generate('file_upload_delete', $parameters); $deleteUrl = $this->router->generate('file_upload_delete', $parameters);
return $this->createResponse( return $this->createResponse(
Response::HTTP_CREATED, Response::HTTP_CREATED,
'New file created', 'New file created',
[ array_merge(
'id' => $file->getId(), $file->toArray(),
'put_url' => $this->router->generate('file_upload_put_content', $parameters), [
'delete_type' => 'DELETE', 'put_url' => $this->router->generate('file_upload_put_content', $parameters),
'delete_url' => $deleteUrl, '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 ] ),
); // 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 ...@@ -142,16 +145,14 @@ class UploadController extends Controller
'File uploaded', 'File uploaded',
[ [
'files' => [ 'files' => [
[ array_merge(
'id' => $file->getId(), $file->toArray(),
'name' => $file->getDisplayName(), [
'type' => $file->getMimeType(), 'url' => $this->router->generate('file_upload_get_content', $parameters),
'size' => $file->getSize(), 'delete_type' => 'DELETE',
'icon' => MimeTypeIcon::getMimeTypeIcon($file->getMimeType()), 'delete_url' => $this->router->generate('file_upload_delete', $parameters),
'url' => $this->router->generate('file_upload_get_content', $parameters), ]
'delete_type' => 'DELETE', )
'delete_url' => $this->router->generate('file_upload_delete', $parameters),
]
] ]
] ]
); );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment