|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace kalanis\Pohoda\Type; |
|
6
|
|
|
|
|
7
|
|
|
use kalanis\Pohoda\AbstractAgenda; |
|
8
|
|
|
use kalanis\Pohoda\Common; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @property Dtos\ActionTypeDto $data |
|
12
|
|
|
*/ |
|
13
|
|
|
class ActionType extends AbstractAgenda |
|
14
|
|
|
{ |
|
15
|
|
|
use Common\SetNamespaceTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* {@inheritdoc} |
|
19
|
|
|
*/ |
|
20
|
8 |
|
public function getXML(): \SimpleXMLElement |
|
21
|
|
|
{ |
|
22
|
8 |
|
if (is_null($this->namespace)) { |
|
23
|
1 |
|
throw new \LogicException('Namespace not set.'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
7 |
|
$xml = $this->createXML()->addChild($this->namespace . ':actionType', '', $this->namespace($this->namespace)); |
|
27
|
7 |
|
$action = $xml->addChild($this->namespace . ':' . ('add/update' == $this->data->type ? 'add' : $this->data->type)); |
|
28
|
|
|
|
|
29
|
7 |
|
if ('add/update' == $this->data->type) { |
|
30
|
1 |
|
$action->addAttribute('update', 'true'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
7 |
|
if (!empty($this->data->filter)) { |
|
34
|
6 |
|
$filter = $action->addChild('ftr:filter', '', $this->namespace('ftr')); |
|
35
|
|
|
|
|
36
|
6 |
|
if (!empty($this->data->agenda)) { |
|
37
|
1 |
|
$filter->addAttribute('agenda', strval($this->data->agenda)); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
6 |
|
foreach ($this->data->filter as $property => $value) { |
|
41
|
6 |
|
$ftr = $filter->addChild('ftr:' . $property, \is_array($value) ? null : \strval($value)); |
|
42
|
|
|
|
|
43
|
6 |
|
if (\is_array($value)) { |
|
44
|
2 |
|
foreach ($value as $tProperty => $tValue) { |
|
45
|
2 |
|
$ftr->addChild('typ:' . $tProperty, \strval($tValue), $this->namespace('typ')); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
7 |
|
return $xml; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* {@inheritDoc} |
|
56
|
|
|
*/ |
|
57
|
10 |
|
protected function getDefaultDto(): Common\Dtos\AbstractDto |
|
58
|
|
|
{ |
|
59
|
10 |
|
return new Dtos\ActionTypeDto(); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|