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