@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | class ContractService |
11 | 11 | { |
12 | 12 | |
13 | - public function __construct( |
|
13 | + public function __construct( |
|
14 | 14 | private EntityManagerInterface $manager, |
15 | 15 | private PdfService $pdf, |
16 | 16 | private ModelService $modelService |
17 | - ) {} |
|
17 | + ) {} |
|
18 | 18 | |
19 | - public function genetateFromModel(Contract $data) |
|
20 | - { |
|
19 | + public function genetateFromModel(Contract $data) |
|
20 | + { |
|
21 | 21 | $file = $data->getContractFile(); |
22 | 22 | if (!$file) |
23 | - $file = new File(); |
|
23 | + $file = new File(); |
|
24 | 24 | |
25 | 25 | $file->setFileType('text'); |
26 | 26 | $file->setExtension('html'); |
@@ -35,28 +35,28 @@ discard block |
||
35 | 35 | $this->manager->flush(); |
36 | 36 | |
37 | 37 | return $data; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function getContractPDFContent(Contract $contract): string |
|
41 | - { |
|
40 | + public function getContractPDFContent(Contract $contract): string |
|
41 | + { |
|
42 | 42 | $content = $contract->getContractFile()->getContent(); |
43 | 43 | |
44 | 44 | if ($contract->getContractFile()->getExtension() == 'pdf') |
45 | - return $content; |
|
45 | + return $content; |
|
46 | 46 | |
47 | 47 | if (empty($content)) { |
48 | - throw new \Exception( |
|
48 | + throw new \Exception( |
|
49 | 49 | sprintf('Houve um erro ao gerar o PDF') |
50 | - ); |
|
50 | + ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | return $this->pdf->convertHtmlToPdf($content); |
54 | - } |
|
54 | + } |
|
55 | 55 | |
56 | 56 | |
57 | - public function afterPersist(Contract $contract) |
|
58 | - { |
|
57 | + public function afterPersist(Contract $contract) |
|
58 | + { |
|
59 | 59 | if ($contract->getStatus()->getRealStatus() == 'open') |
60 | - return $this->genetateFromModel($contract); |
|
61 | - } |
|
60 | + return $this->genetateFromModel($contract); |
|
61 | + } |
|
62 | 62 | } |
@@ -19,8 +19,9 @@ discard block |
||
19 | 19 | public function genetateFromModel(Contract $data) |
20 | 20 | { |
21 | 21 | $file = $data->getContractFile(); |
22 | - if (!$file) |
|
23 | - $file = new File(); |
|
22 | + if (!$file) { |
|
23 | + $file = new File(); |
|
24 | + } |
|
24 | 25 | |
25 | 26 | $file->setFileType('text'); |
26 | 27 | $file->setExtension('html'); |
@@ -41,8 +42,9 @@ discard block |
||
41 | 42 | { |
42 | 43 | $content = $contract->getContractFile()->getContent(); |
43 | 44 | |
44 | - if ($contract->getContractFile()->getExtension() == 'pdf') |
|
45 | - return $content; |
|
45 | + if ($contract->getContractFile()->getExtension() == 'pdf') { |
|
46 | + return $content; |
|
47 | + } |
|
46 | 48 | |
47 | 49 | if (empty($content)) { |
48 | 50 | throw new \Exception( |
@@ -56,7 +58,8 @@ discard block |
||
56 | 58 | |
57 | 59 | public function afterPersist(Contract $contract) |
58 | 60 | { |
59 | - if ($contract->getStatus()->getRealStatus() == 'open') |
|
60 | - return $this->genetateFromModel($contract); |
|
61 | + if ($contract->getStatus()->getRealStatus() == 'open') { |
|
62 | + return $this->genetateFromModel($contract); |
|
63 | + } |
|
61 | 64 | } |
62 | 65 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | $contractProviders = $contract->getPeoples() |
136 | - ->filter(function ($contractPeople) { |
|
136 | + ->filter(function($contractPeople) { |
|
137 | 137 | return $contractPeople->getPeopleType() == 'Beneficiary'; |
138 | 138 | }); |
139 | 139 | if ($contractProviders->isEmpty()) { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | $contractParticipants = $contract->getPeoples() |
150 | - ->filter(function ($contractPeople) { |
|
150 | + ->filter(function($contractPeople) { |
|
151 | 151 | return $contractPeople->getPeopleType() != 'Beneficiary'; |
152 | 152 | }); |
153 | 153 | if ($contractParticipants->isEmpty()) { |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | protected function getContractContractorSignerName(Contract $contract): string |
167 | 167 | { |
168 | 168 | $contractPayers = $contract->getPeoples() |
169 | - ->filter(function ($contractPeople) { |
|
169 | + ->filter(function($contractPeople) { |
|
170 | 170 | return $contractPeople->getPeopleType() == 'Contractor'; |
171 | 171 | }); |
172 | 172 | if ($contractPayers->isEmpty()) { |