1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of riesenia/pohoda package. |
4
|
|
|
* |
5
|
|
|
* Licensed under the MIT License |
6
|
|
|
* (c) RIESENIA.com |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace Riesenia\Pohoda\PrintRequest; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AbstractAgenda; |
15
|
|
|
use Riesenia\Pohoda\Common; |
16
|
|
|
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
class Parameters extends AbstractAgenda |
20
|
|
|
{ |
21
|
|
|
/** @var string[] */ |
22
|
|
|
protected array $elements = ['copy', 'datePrint']; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
3 |
|
public function __construct( |
28
|
|
|
Common\NamespacesPaths $namespacesPaths, |
29
|
|
|
SanitizeEncoding $sanitizeEncoding, |
30
|
|
|
array $data, |
31
|
|
|
string $ico, |
32
|
|
|
bool $resolveOptions = true, |
33
|
|
|
) |
34
|
|
|
{ |
35
|
3 |
|
$factory = new ParameterFactory($namespacesPaths, $sanitizeEncoding, $ico); |
36
|
|
|
|
37
|
3 |
|
foreach ($factory->getKeys() as $key) { |
38
|
|
|
// fill elements from factory |
39
|
3 |
|
$this->elements[] = $key; |
40
|
|
|
// add instance to data |
41
|
3 |
|
if (isset($data[$key])) { |
42
|
3 |
|
$data[$key] = $factory->getByKey($key, $data[$key], $resolveOptions); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
3 |
|
parent::__construct($namespacesPaths, $sanitizeEncoding, $data, $ico, $resolveOptions); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
2 |
|
public function getXML(): \SimpleXMLElement |
53
|
|
|
{ |
54
|
2 |
|
$xml = $this->createXML()->addChild('prn:parameters', '', $this->namespace('prn')); |
55
|
|
|
|
56
|
2 |
|
$this->addElements($xml, $this->elements, 'prn'); |
57
|
|
|
|
58
|
2 |
|
return $xml; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* {@inheritdoc} |
63
|
|
|
*/ |
64
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
65
|
|
|
{ |
66
|
|
|
// available options |
67
|
1 |
|
$resolver->setDefined($this->elements); |
68
|
|
|
|
69
|
1 |
|
$resolver->setNormalizer('copy', $this->normalizerFactory->getClosure('int')); |
70
|
1 |
|
$resolver->setNormalizer('datePrint', $this->normalizerFactory->getClosure('string')); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|