|
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
|
|
|
|
|
14
|
|
|
use Riesenia\Pohoda\AddressBook\Header; |
|
15
|
|
|
use Riesenia\Pohoda\ValueTransformer\SanitizeEncoding; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
class AddressBook extends AbstractAgenda |
|
19
|
|
|
{ |
|
20
|
|
|
use Common\AddActionTypeTrait; |
|
21
|
|
|
use Common\AddParameterToHeaderTrait; |
|
22
|
|
|
|
|
23
|
1 |
|
public function getImportRoot(): string |
|
24
|
|
|
{ |
|
25
|
1 |
|
return 'lAdb:addressbook'; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* {@inheritdoc} |
|
30
|
|
|
*/ |
|
31
|
7 |
|
public function __construct( |
|
32
|
|
|
Common\NamespacesPaths $namespacesPaths, |
|
33
|
|
|
SanitizeEncoding $sanitizeEncoding, |
|
34
|
|
|
array $data, |
|
35
|
|
|
string $companyRegistrationNumber, |
|
36
|
|
|
bool $resolveOptions = true, |
|
37
|
|
|
) |
|
38
|
|
|
{ |
|
39
|
|
|
// pass to header |
|
40
|
7 |
|
if (!empty($data)) { |
|
41
|
6 |
|
$data = ['header' => new Header($namespacesPaths, $sanitizeEncoding, $data, $companyRegistrationNumber, $resolveOptions)]; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
7 |
|
parent::__construct($namespacesPaths, $sanitizeEncoding, $data, $companyRegistrationNumber, $resolveOptions); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* {@inheritdoc} |
|
49
|
|
|
*/ |
|
50
|
6 |
|
public function getXML(): \SimpleXMLElement |
|
51
|
|
|
{ |
|
52
|
6 |
|
$xml = $this->createXML()->addChild('adb:addressbook', '', $this->namespace('adb')); |
|
53
|
6 |
|
$xml->addAttribute('version', '2.0'); |
|
54
|
|
|
|
|
55
|
6 |
|
$this->addElements($xml, ['actionType', 'header'], 'adb'); |
|
56
|
|
|
|
|
57
|
6 |
|
return $xml; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
1 |
|
protected function configureOptions(Common\OptionsResolver $resolver): void |
|
64
|
|
|
{ |
|
65
|
|
|
// available options |
|
66
|
1 |
|
$resolver->setDefined(['header']); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|