@@ -11,18 +11,18 @@ discard block |
||
11 | 11 | class ContractService |
12 | 12 | { |
13 | 13 | |
14 | - public function __construct( |
|
14 | + public function __construct( |
|
15 | 15 | private EntityManagerInterface $manager, |
16 | 16 | private PdfService $pdf, |
17 | 17 | private ModelService $modelService, |
18 | 18 | private StatusService $statusService |
19 | - ) {} |
|
19 | + ) {} |
|
20 | 20 | |
21 | - public function genetateFromModel(Contract $data) |
|
22 | - { |
|
21 | + public function genetateFromModel(Contract $data) |
|
22 | + { |
|
23 | 23 | $file = $data->getContractFile(); |
24 | 24 | if (!$file) |
25 | - $file = new File(); |
|
25 | + $file = new File(); |
|
26 | 26 | |
27 | 27 | $file->setFileType('text'); |
28 | 28 | $file->setExtension('html'); |
@@ -34,38 +34,38 @@ discard block |
||
34 | 34 | |
35 | 35 | $data->setContractFile($file); |
36 | 36 | $data->setStatus( |
37 | - $this->statusService->discoveryStatus( |
|
37 | + $this->statusService->discoveryStatus( |
|
38 | 38 | 'open', |
39 | 39 | 'open', |
40 | 40 | $data->getStatus()->getContext() |
41 | - ) |
|
41 | + ) |
|
42 | 42 | ); |
43 | 43 | $this->manager->persist($data); |
44 | 44 | $this->manager->flush(); |
45 | 45 | |
46 | 46 | return $data; |
47 | - } |
|
47 | + } |
|
48 | 48 | |
49 | - public function getContractPDFContent(Contract $contract): string |
|
50 | - { |
|
49 | + public function getContractPDFContent(Contract $contract): string |
|
50 | + { |
|
51 | 51 | $content = $contract->getContractFile()->getContent(); |
52 | 52 | |
53 | 53 | if ($contract->getContractFile()->getExtension() == 'pdf') |
54 | - return $content; |
|
54 | + return $content; |
|
55 | 55 | |
56 | 56 | if (empty($content)) { |
57 | - throw new \Exception( |
|
57 | + throw new \Exception( |
|
58 | 58 | sprintf('Houve um erro ao gerar o PDF') |
59 | - ); |
|
59 | + ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | return $this->pdf->convertHtmlToPdf($content); |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - public function postPersist(Contract $contract) |
|
67 | - { |
|
66 | + public function postPersist(Contract $contract) |
|
67 | + { |
|
68 | 68 | if ($contract->getStatus()->getRealStatus() == 'open') |
69 | - return $this->genetateFromModel($contract); |
|
70 | - } |
|
69 | + return $this->genetateFromModel($contract); |
|
70 | + } |
|
71 | 71 | } |