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\IntParam\Settings; |
15
|
|
|
|
16
|
|
|
class IntParam extends AbstractAgenda |
17
|
|
|
{ |
18
|
|
|
/** @var string[] */ |
19
|
|
|
protected array $elements = ['name', 'description', 'parameterType', 'parameterSettings']; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* {@inheritdoc} |
23
|
|
|
*/ |
24
|
3 |
|
public function setData(array $data): parent |
25
|
|
|
{ |
26
|
|
|
// prepare empty parameter list for list |
27
|
3 |
|
if ('listValue' == $data['parameterType']) { |
28
|
1 |
|
$data['parameterSettings'] = ['parameterList' => []]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
// process settings |
32
|
3 |
|
if (isset($data['parameterSettings'])) { |
33
|
3 |
|
$parameterSettings = new Settings($this->namespacesPaths, $this->sanitizeEncoding, $this->companyRegistrationNumber, $this->resolveOptions, $this->normalizerFactory); |
34
|
3 |
|
$data['parameterSettings'] = $parameterSettings->setDirectionalVariable($this->useOneDirectionalVariables)->setData($data['parameterSettings']); |
35
|
|
|
} |
36
|
|
|
|
37
|
3 |
|
return parent::setData($data); |
|
|
|
|
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
public function getImportRoot(): string |
41
|
|
|
{ |
42
|
1 |
|
return 'lst:intParamDetail'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* {@inheritdoc} |
47
|
|
|
*/ |
48
|
2 |
|
public function getXML(): \SimpleXMLElement |
49
|
|
|
{ |
50
|
2 |
|
$xml = $this->createXML()->addChild('ipm:intParamDetail', '', $this->namespace('ipm')); |
51
|
2 |
|
$xml->addAttribute('version', '2.0'); |
52
|
|
|
|
53
|
2 |
|
$param = $xml->addChild('ipm:intParam'); |
54
|
2 |
|
$this->addElements($param, $this->elements, 'ipm'); |
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($this->elements); |
66
|
|
|
|
67
|
|
|
// validate / format options |
68
|
1 |
|
$resolver->setRequired('name'); |
69
|
1 |
|
$resolver->setRequired('parameterType'); |
70
|
1 |
|
$resolver->setAllowedValues('parameterType', ['textValue', 'currencyValue', 'booleanValue', 'numberValue', 'integerValue', 'datetimeValue', 'unit', 'listValue']); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|