|
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->dependenciesFactory); |
|
29
|
3 |
|
$record |
|
30
|
3 |
|
->setDirectionalVariable($this->useOneDirectionalVariables) |
|
31
|
3 |
|
->setResolveOptions($this->resolveOptions) |
|
32
|
3 |
|
->setData($data['record']); |
|
33
|
3 |
|
$data['record'] = $record; |
|
34
|
|
|
|
|
35
|
|
|
// process printer settings |
|
36
|
3 |
|
$printerSettings = new PrintRequest\PrinterSettings($this->dependenciesFactory); |
|
37
|
3 |
|
$printerSettings |
|
38
|
3 |
|
->setDirectionalVariable($this->useOneDirectionalVariables) |
|
39
|
3 |
|
->setResolveOptions($this->resolveOptions) |
|
40
|
3 |
|
->setData($data['printerSettings']); |
|
41
|
3 |
|
$data['printerSettings'] = $printerSettings; |
|
42
|
|
|
|
|
43
|
3 |
|
return parent::setData($data); |
|
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
2 |
|
public function getXML(): \SimpleXMLElement |
|
50
|
|
|
{ |
|
51
|
2 |
|
$xml = $this->createXML()->addChild('prn:print', '', $this->namespace('prn')); |
|
52
|
2 |
|
$xml->addAttribute('version', '1.0'); |
|
53
|
|
|
|
|
54
|
2 |
|
$this->addElements($xml, ['record', 'printerSettings'], '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(['record', 'printerSettings']); |
|
66
|
|
|
|
|
67
|
1 |
|
$resolver->setRequired('record'); |
|
68
|
1 |
|
$resolver->setRequired('printerSettings'); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|