1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the CMS Kernel package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016-present LIN3S <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace LIN3S\CMSKernel\Infrastructure\BenGorFileBundle\HttpAction; |
13
|
|
|
|
14
|
|
|
use BenGorFile\File\Domain\Model\FileAlreadyExistsException; |
15
|
|
|
use BenGorFile\File\Domain\Model\FileDoesNotExistException; |
16
|
|
|
use BenGorFile\File\Domain\Model\FileMimeTypeDoesNotSupportException; |
17
|
|
|
use BenGorFile\File\Domain\Model\FileNameInvalidException; |
18
|
|
|
use BenGorFile\File\Infrastructure\Application\FileCommandBus; |
19
|
|
|
use BenGorFile\FileBundle\Controller\SuffixNumberUploadAction; |
20
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
21
|
|
|
use Symfony\Component\HttpFoundation\Request; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @author Beñat Espiña <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class AjaxFileUploadAction |
27
|
|
|
{ |
28
|
|
|
use SuffixNumberUploadAction; |
29
|
|
|
|
30
|
|
|
private $commandBus; |
31
|
|
|
|
32
|
|
|
public function __construct(FileCommandBus $commandBus) |
33
|
|
|
{ |
34
|
|
|
$this->commandBus = $commandBus; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function __invoke(Request $request) |
38
|
|
|
{ |
39
|
|
|
try { |
40
|
|
|
$fileData = $this->upload($request, $this->commandBus, 'file'); |
41
|
|
|
} catch (FileDoesNotExistException $exception) { |
|
|
|
|
42
|
|
|
return new JsonResponse($exception->getMessage(), 404); |
43
|
|
|
} catch (FileAlreadyExistsException $exception) { |
|
|
|
|
44
|
|
|
return new JsonResponse($exception->getMessage(), 409); |
45
|
|
|
} catch (FileMimeTypeDoesNotSupportException $exception) { |
|
|
|
|
46
|
|
|
return new JsonResponse($exception->getMessage(), 400); |
47
|
|
|
} catch (FileNameInvalidException $exception) { |
|
|
|
|
48
|
|
|
return new JsonResponse($exception->getMessage(), 400); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return new JsonResponse($fileData); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
Scrutinizer analyzes your
composer.json
/composer.lock
file if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.