1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Controller; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Device; |
|
|
|
|
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
|
7
|
|
|
use Symfony\Component\HttpFoundation\JsonResponse; |
|
|
|
|
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
9
|
|
|
use ControleOnline\Entity\Order; |
10
|
|
|
use ControleOnline\Entity\Spool; |
|
|
|
|
11
|
|
|
use ControleOnline\Service\HydratorService; |
|
|
|
|
12
|
|
|
use ControleOnline\Service\OrderPrintService; |
13
|
|
|
use Exception; |
14
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
15
|
|
|
|
16
|
|
|
class PrintOrderAction |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
public function __construct( |
21
|
|
|
private EntityManagerInterface $entityManager, |
22
|
|
|
private OrderPrintService $print, |
23
|
|
|
private HydratorService $hydratorService |
24
|
|
|
|
25
|
|
|
) {} |
26
|
|
|
|
27
|
|
|
public function __invoke(Request $request, int $id): JsonResponse |
28
|
|
|
{ |
29
|
|
|
try { |
30
|
|
|
$order = $this->entityManager->getRepository(Order::class)->find($id); |
31
|
|
|
if (!$order) { |
32
|
|
|
return new JsonResponse(['error' => 'Order not found'], 404); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
$data = json_decode($request->getContent(), true); |
36
|
|
|
$device = $this->entityManager->getRepository(Device::class)->findOneBy([ |
37
|
|
|
'device' => $data['device'] |
38
|
|
|
]); |
39
|
|
|
|
40
|
|
|
$printData = $this->print->generatePrintData($order, $device); |
41
|
|
|
return new JsonResponse($this->hydratorService->item(Spool::class, $printData->getId(), "spool_item:read"), Response::HTTP_OK); |
42
|
|
|
} catch (Exception $e) { |
43
|
|
|
return new JsonResponse($this->hydratorService->error($e)); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
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