1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of riesenia/pohoda package. |
5
|
|
|
* |
6
|
|
|
* Licensed under the MIT License |
7
|
|
|
* (c) RIESENIA.com |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Riesenia\Pohoda\PrintRequest; |
13
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
15
|
|
|
use Riesenia\Pohoda\Common; |
16
|
|
|
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding; |
17
|
|
|
|
18
|
|
|
class PrinterSettings extends AbstractAgenda |
19
|
|
|
{ |
20
|
|
|
/** @var string[] */ |
21
|
|
|
protected array $elements = ['report', 'printer', 'pdf', 'parameters']; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
3 |
|
public function setData(array $data): parent |
27
|
|
|
{ |
28
|
|
|
// process report |
29
|
3 |
|
if (isset($data['report'])) { |
30
|
3 |
|
$report = new Report($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
31
|
3 |
|
$data['report'] = $report->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['report']); |
32
|
|
|
} |
33
|
|
|
// process pdf |
34
|
3 |
|
if (isset($data['pdf'])) { |
35
|
3 |
|
$pdf = new Pdf($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
36
|
3 |
|
$data['pdf'] = $pdf->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['pdf']); |
37
|
|
|
} |
38
|
|
|
// process parameters |
39
|
3 |
|
if (isset($data['parameters'])) { |
40
|
3 |
|
$parameters = new Parameters($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
41
|
3 |
|
$data['parameters'] = $parameters->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['parameters']); |
42
|
|
|
} |
43
|
|
|
|
44
|
3 |
|
return parent::setData($data); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
|
|
*/ |
50
|
2 |
|
public function getXML(): \SimpleXMLElement |
51
|
|
|
{ |
52
|
2 |
|
$xml = $this->createXML()->addChild('prn:printerSettings', '', $this->namespace('prn')); |
53
|
|
|
|
54
|
2 |
|
$this->addElements($xml, $this->elements, 'prn'); |
55
|
|
|
|
56
|
2 |
|
return $xml; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* {@inheritdoc} |
61
|
|
|
*/ |
62
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
63
|
|
|
{ |
64
|
|
|
// available options |
65
|
1 |
|
$resolver->setDefined($this->elements); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|