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;
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),
]
)
]
]
);
......
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