ControleOnline /
api-platform-common
| 1 | <?php |
||
| 2 | |||
| 3 | namespace ControleOnline\Controller; |
||
| 4 | |||
| 5 | use Symfony\Component\HttpFoundation\Request; |
||
|
0 ignored issues
–
show
|
|||
| 6 | use Symfony\Component\HttpFoundation\Response; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\Response was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 7 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpKe...BadRequestHttpException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 8 | use ControleOnline\Entity\File; |
||
| 9 | use ControleOnline\Entity\People; |
||
|
0 ignored issues
–
show
The type
ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | use ControleOnline\Service\FileService; |
||
| 11 | use Doctrine\ORM\EntityManagerInterface; |
||
|
0 ignored issues
–
show
The type
Doctrine\ORM\EntityManagerInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 12 | use ControleOnline\Service\HydratorService; |
||
| 13 | use Exception; |
||
| 14 | use Symfony\Component\HttpFoundation\JsonResponse; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\HttpFoundation\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | |||
| 16 | class FileUploadController |
||
| 17 | { |
||
| 18 | |||
| 19 | public function __construct( |
||
| 20 | private EntityManagerInterface $em, |
||
| 21 | private HydratorService $hydratorService, |
||
| 22 | private FileService $fileService |
||
| 23 | ) {} |
||
| 24 | |||
| 25 | public function __invoke(Request $request): Response |
||
| 26 | { |
||
| 27 | |||
| 28 | try { |
||
| 29 | $file = $request->files->get('file'); |
||
| 30 | $people_id = $request->request->get('people'); |
||
| 31 | $context = $request->request->get('context'); |
||
| 32 | //$file_id = $request->request->get('id'); |
||
| 33 | |||
| 34 | |||
| 35 | if (!$file) { |
||
| 36 | throw new BadRequestHttpException('No file provided'); |
||
| 37 | } |
||
| 38 | |||
| 39 | $content = file_get_contents($file->getPathname()); |
||
| 40 | $fileType = explode('/', $file->getClientMimeType()); |
||
| 41 | $originalFilename = $file->getClientOriginalName(); |
||
| 42 | |||
| 43 | //if ($file_id) |
||
| 44 | // $fileEntity = $this->em->getRepository(File::class)->find($file_id); |
||
| 45 | //if (!$fileEntity) |
||
| 46 | $people = $this->em->getRepository(People::class)->find($people_id); |
||
| 47 | |||
| 48 | $fileEntity = $this->fileService->addFile($people, $content, $context, $originalFilename, $fileType[0], $fileType[1]); |
||
| 49 | |||
| 50 | return new JsonResponse($this->hydratorService->data($fileEntity, 'file:read'), Response::HTTP_CREATED); |
||
| 51 | } catch (Exception $e) { |
||
| 52 | return new JsonResponse($this->hydratorService->error($e)); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths