| Conditions | 2 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | 3 | public function uploadAction($name = null) |
|
| 22 | { |
||
| 23 | try { |
||
| 24 | 3 | $this->checkCredentials(); |
|
| 25 | |||
| 26 | /** @var $fileCollection FileCollection */ |
||
| 27 | 2 | $fileCollection = $this->get('file_collection_manager')->getOrCreate($name); |
|
| 28 | |||
| 29 | 2 | $newFiles = $this->get('upload_manager')->upload( |
|
| 30 | $fileCollection |
||
| 31 | 2 | ); |
|
| 32 | |||
| 33 | 2 | return new JsonResponse(array( |
|
| 34 | 2 | 'status' => 'ok', |
|
| 35 | 2 | 'collection_name' => $fileCollection->getName(), |
|
| 36 | 'files' => $newFiles |
||
| 37 | 2 | )); |
|
| 38 | 1 | } catch (\Exception $e) { |
|
| 39 | 1 | return new JsonResponse(array( |
|
| 40 | 1 | 'status' => 'error', |
|
| 41 | 1 | 'message' => $e->getMessage() |
|
| 42 | 1 | )); |
|
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 47 |