@@ -12,18 +12,18 @@ discard block |
||
12 | 12 | class SignatureService |
13 | 13 | { |
14 | 14 | |
15 | - public function __construct( |
|
15 | + public function __construct( |
|
16 | 16 | private EntityManagerInterface $manager, |
17 | 17 | private PeopleRoleService $peopleRoleService, |
18 | 18 | private PdfService $pdf, |
19 | 19 | private ModelService $modelService |
20 | - ) {} |
|
20 | + ) {} |
|
21 | 21 | |
22 | - public function genetateFromModel(Contract $data) |
|
23 | - { |
|
22 | + public function genetateFromModel(Contract $data) |
|
23 | + { |
|
24 | 24 | $file = $data->getContractFile(); |
25 | 25 | if (!$file) |
26 | - $file = new File(); |
|
26 | + $file = new File(); |
|
27 | 27 | |
28 | 28 | $file->setFileType('text'); |
29 | 29 | $file->setExtension('html'); |
@@ -32,83 +32,83 @@ discard block |
||
32 | 32 | $this->manager->flush(); |
33 | 33 | |
34 | 34 | return $data; |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - public function getContractPDFContent(Contract $contract): string |
|
39 | - { |
|
38 | + public function getContractPDFContent(Contract $contract): string |
|
39 | + { |
|
40 | 40 | $content = $contract->getContractFile()->getContent(); |
41 | 41 | |
42 | 42 | if ($contract->getContractFile()->getExtension() == 'pdf') |
43 | - return $content; |
|
43 | + return $content; |
|
44 | 44 | |
45 | 45 | if (empty($content)) { |
46 | - throw new \Exception( |
|
46 | + throw new \Exception( |
|
47 | 47 | sprintf('Houve um erro ao gerar o PDF') |
48 | - ); |
|
48 | + ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $this->pdf->convertHtmlToPdf($content); |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - public function getFactory(?string $factoryName = null): ?SignatureFactory |
|
55 | - { |
|
54 | + public function getFactory(?string $factoryName = null): ?SignatureFactory |
|
55 | + { |
|
56 | 56 | $providerName = $factoryName === null ? |
57 | 57 | $this->getDefaultProviderFromConfig() : $factoryName; |
58 | 58 | |
59 | 59 | if ($providerName === null) { |
60 | - return null; |
|
60 | + return null; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $provider = sprintf( |
64 | - '\\App\\Library\\Provider\\Signature\\%s\\Factory', |
|
65 | - ucfirst(strtolower($providerName)) |
|
64 | + '\\App\\Library\\Provider\\Signature\\%s\\Factory', |
|
65 | + ucfirst(strtolower($providerName)) |
|
66 | 66 | ); |
67 | 67 | |
68 | 68 | if (!class_exists($provider)) { |
69 | - throw new \Exception('Signature provider factory not found'); |
|
69 | + throw new \Exception('Signature provider factory not found'); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return new $provider( |
73 | - $this->getProviderConfig($providerName) |
|
73 | + $this->getProviderConfig($providerName) |
|
74 | 74 | ); |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - private function getProviderConfig(string $providerName): ?array |
|
79 | - { |
|
78 | + private function getProviderConfig(string $providerName): ?array |
|
79 | + { |
|
80 | 80 | |
81 | 81 | $myCompany = $this->peopleRoleService->getMainCompany(); |
82 | 82 | if ($myCompany instanceof People) { |
83 | 83 | |
84 | - return $this->manager->getRepository(Config::class) |
|
84 | + return $this->manager->getRepository(Config::class) |
|
85 | 85 | ->getKeyValuesByPeople( |
86 | - $myCompany, |
|
87 | - strtolower($providerName) |
|
86 | + $myCompany, |
|
87 | + strtolower($providerName) |
|
88 | 88 | ); |
89 | 89 | } |
90 | 90 | |
91 | 91 | throw new \Exception('Company not found'); |
92 | - } |
|
92 | + } |
|
93 | 93 | |
94 | - private function getDefaultProviderFromConfig(): ?string |
|
95 | - { |
|
94 | + private function getDefaultProviderFromConfig(): ?string |
|
95 | + { |
|
96 | 96 | $myCompany = $this->peopleRoleService->getMainCompany(); |
97 | 97 | if ($myCompany instanceof People) { |
98 | - $configs = $this->manager->getRepository(Config::class) |
|
98 | + $configs = $this->manager->getRepository(Config::class) |
|
99 | 99 | ->getKeyValuesByPeople( |
100 | - $myCompany, |
|
101 | - 'provider' |
|
100 | + $myCompany, |
|
101 | + 'provider' |
|
102 | 102 | ); |
103 | 103 | |
104 | - if ($configs === null) { |
|
104 | + if ($configs === null) { |
|
105 | 105 | return null; |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - return isset($configs['provider-signature']) ? |
|
108 | + return isset($configs['provider-signature']) ? |
|
109 | 109 | $configs['provider-signature'] : null; |
110 | 110 | } |
111 | 111 | |
112 | 112 | throw new \Exception('Company not found'); |
113 | - } |
|
113 | + } |
|
114 | 114 | } |