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
|
|
|
|
17
|
|
|
class Parameters extends AbstractAgenda |
18
|
|
|
{ |
19
|
|
|
/** @var string[] */ |
20
|
|
|
protected array $elements = ['copy', 'datePrint']; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
3 |
|
public function setData(array $data): parent |
26
|
|
|
{ |
27
|
3 |
|
$factory = new ParameterFactory($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->normalizerFactory); |
28
|
|
|
|
29
|
3 |
|
foreach ($factory->getKeys() as $key) { |
30
|
|
|
// fill elements from factory |
31
|
3 |
|
$this->elements[] = $key; |
32
|
|
|
// add instance to data |
33
|
3 |
|
if (isset($data[$key])) { |
34
|
3 |
|
$data[$key] = $factory->getByKey($key, $this->resolveOptions)->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data[$key]); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
|
38
|
3 |
|
return parent::setData($data); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
2 |
|
public function getXML(): \SimpleXMLElement |
45
|
|
|
{ |
46
|
2 |
|
$xml = $this->createXML()->addChild('prn:parameters', '', $this->namespace('prn')); |
47
|
|
|
|
48
|
2 |
|
$this->addElements($xml, $this->elements, '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($this->elements); |
60
|
|
|
|
61
|
1 |
|
$resolver->setNormalizer('copy', $this->normalizerFactory->getClosure('int')); |
62
|
1 |
|
$resolver->setNormalizer('datePrint', $this->normalizerFactory->getClosure('string')); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|