|
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; |
|
12
|
|
|
|
|
13
|
|
|
use Riesenia\Pohoda\Common\OptionsResolver; |
|
14
|
|
|
use Symfony\Component\OptionsResolver\Options; |
|
15
|
|
|
|
|
16
|
|
|
class ListStock extends AbstractAgenda |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* {@inheritdoc} |
|
20
|
|
|
*/ |
|
21
|
1 |
|
public function getXML(): \SimpleXMLElement |
|
22
|
|
|
{ |
|
23
|
1 |
|
$xml = $this->createXML()->addChild($this->data['namespace'] . ':list' . $this->data['type'], '', $this->namespace(strval($this->data['namespace']))); |
|
24
|
1 |
|
$xml->addAttribute('version', '2.0'); |
|
25
|
|
|
|
|
26
|
1 |
|
if ($this->data['timestamp']) { |
|
27
|
1 |
|
$date = $this->data['timestamp']; |
|
28
|
1 |
|
if (is_object($date) && is_a($date, \DateTimeInterface::class)) { |
|
29
|
1 |
|
$date = $date->format('Y-m-d\TH:i:s'); |
|
30
|
|
|
} |
|
31
|
1 |
|
$xml->addAttribute('dateTimeStamp', strval($date)); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
1 |
|
if ($this->data['validFrom']) { |
|
35
|
1 |
|
$dateFrom = $this->data['validFrom']; |
|
36
|
1 |
|
if (is_object($date) && is_a($dateFrom, \DateTimeInterface::class)) { |
|
|
|
|
|
|
37
|
1 |
|
$dateFrom = $dateFrom->format('Y-m-d'); |
|
38
|
|
|
} |
|
39
|
1 |
|
$xml->addAttribute('dateValidFrom', strval($dateFrom)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
if ($this->data['state']) { |
|
43
|
1 |
|
$xml->addAttribute('state', strval($this->data['state'])); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
return $xml; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
1 |
|
protected function configureOptions(OptionsResolver $resolver): void |
|
53
|
|
|
{ |
|
54
|
|
|
// available options |
|
55
|
1 |
|
$resolver->setDefined(['type', 'namespace', 'timestamp', 'validFrom', 'state']); |
|
56
|
|
|
|
|
57
|
|
|
// validate / format options |
|
58
|
1 |
|
$resolver->setRequired('type'); |
|
59
|
1 |
|
$resolver->setNormalizer('type', $this->normalizerFactory->getClosure('list_request_type')); |
|
60
|
1 |
|
$resolver->setDefault('namespace', function (Options $options) { |
|
|
|
|
|
|
61
|
1 |
|
return 'lst'; |
|
62
|
1 |
|
}); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|