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; |
||
13 | |||
14 | /** |
||
15 | * @property array{ |
||
16 | * record: PrintRequest\Record, |
||
17 | * printerSettings: PrintRequest\PrinterSettings, |
||
18 | * } $data |
||
19 | */ |
||
20 | class PrintRequest extends AbstractAgenda |
||
21 | { |
||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 3 | public function setData(array $data): parent |
|
26 | { |
||
27 | // process record |
||
28 | 3 | $record = new PrintRequest\Record($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
|
29 | 3 | $record->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['record']); |
|
30 | 3 | $data['record'] = $record; |
|
31 | |||
32 | // process printer settings |
||
33 | 3 | $printerSettings = new PrintRequest\PrinterSettings($this->namespacesPaths, $this->sanitizeEncoding, $this->normalizerFactory); |
|
34 | 3 | $printerSettings->setDirectionalVariable($this->useOneDirectionalVariables)->setResolveOptions($this->resolveOptions)->setData($data['printerSettings']); |
|
35 | 3 | $data['printerSettings'] = $printerSettings; |
|
36 | |||
37 | 3 | return parent::setData($data); |
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | 2 | public function getXML(): \SimpleXMLElement |
|
44 | { |
||
45 | 2 | $xml = $this->createXML()->addChild('prn:print', '', $this->namespace('prn')); |
|
46 | 2 | $xml->addAttribute('version', '1.0'); |
|
47 | |||
48 | 2 | $this->addElements($xml, ['record', 'printerSettings'], 'prn'); |
|
49 | |||
50 | 2 | return $xml; |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 1 | protected function configureOptions(Common\OptionsResolver $resolver): void |
|
57 | { |
||
58 | // available options |
||
59 | 1 | $resolver->setDefined(['record', 'printerSettings']); |
|
60 | |||
61 | 1 | $resolver->setRequired('record'); |
|
62 | 1 | $resolver->setRequired('printerSettings'); |
|
63 | } |
||
64 | } |
||
65 |