|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace kalanis\Pohoda\Document; |
|
6
|
|
|
|
|
7
|
|
|
use kalanis\Pohoda\Common; |
|
8
|
|
|
use kalanis\Pohoda\Type; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @property Common\Dtos\AbstractHeaderDto $data |
|
12
|
|
|
*/ |
|
13
|
|
|
abstract class AbstractHeader extends AbstractPart |
|
14
|
|
|
{ |
|
15
|
|
|
use Common\AddParameterTrait; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* {@inheritdoc} |
|
19
|
|
|
*/ |
|
20
|
54 |
|
public function setData(Common\Dtos\AbstractDto $data): parent |
|
21
|
|
|
{ |
|
22
|
|
|
// process partner identity |
|
23
|
54 |
|
if (isset($data->partnerIdentity)) { |
|
24
|
43 |
|
$parentIdentity = new Type\Address($this->dependenciesFactory); |
|
25
|
43 |
|
$parentIdentity |
|
26
|
43 |
|
->setDirectionalVariable($this->useOneDirectionalVariables) |
|
27
|
43 |
|
->setResolveOptions($this->resolveOptions) |
|
28
|
43 |
|
->setData($data->partnerIdentity); |
|
29
|
43 |
|
$data->partnerIdentity = $parentIdentity; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
// process my identity |
|
33
|
54 |
|
if (isset($data->myIdentity)) { |
|
34
|
27 |
|
$myIdentity = new Type\MyAddress($this->dependenciesFactory); |
|
35
|
27 |
|
$myIdentity |
|
36
|
27 |
|
->setDirectionalVariable($this->useOneDirectionalVariables) |
|
37
|
27 |
|
->setResolveOptions($this->resolveOptions) |
|
38
|
27 |
|
->setData($data->myIdentity); |
|
39
|
27 |
|
$data->myIdentity = $myIdentity; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
54 |
|
return parent::setData($data); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
38 |
|
public function getXML(): \SimpleXMLElement |
|
49
|
|
|
{ |
|
50
|
38 |
|
if (is_null($this->namespace)) { |
|
51
|
1 |
|
throw new \LogicException('Namespace not set.'); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
37 |
|
if (is_null($this->nodePrefix)) { |
|
55
|
1 |
|
throw new \LogicException('Node name prefix not set.'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
36 |
|
$xml = $this->createXML()->addChild($this->namespace . ':' . $this->nodePrefix . 'Header', '', $this->namespace($this->namespace)); |
|
59
|
|
|
|
|
60
|
36 |
|
$this->addElements($xml, $this->getDataElements(), $this->namespace); |
|
61
|
|
|
|
|
62
|
36 |
|
return $xml; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|