1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SimpleSAML\XMLSchema\XML; |
6
|
|
|
|
7
|
|
|
use DOMElement; |
8
|
|
|
use SimpleSAML\XMLSchema\Type\IDValue; |
9
|
|
|
use SimpleSAML\XMLSchema\Type\QNameValue; |
10
|
|
|
use SimpleSAML\XMLSchema\XML\Interface\TypeDefParticleInterface; |
11
|
|
|
use SimpleSAML\XMLSchema\XML\Trait\AttrDeclsTrait; |
12
|
|
|
use SimpleSAML\XMLSchema\XML\Trait\TypeDefParticleTrait; |
13
|
|
|
|
14
|
|
|
use function strval; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Abstract class representing the extensionType-type. |
18
|
|
|
* |
19
|
|
|
* @package simplesamlphp/xml-common |
20
|
|
|
*/ |
21
|
|
|
abstract class AbstractExtensionType extends AbstractAnnotated |
22
|
|
|
{ |
23
|
|
|
use AttrDeclsTrait; |
24
|
|
|
use TypeDefParticleTrait; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* AbstractExtensionType constructor |
29
|
|
|
* |
30
|
|
|
* @param \SimpleSAML\XMLSchema\Type\QNameValue $base |
31
|
|
|
* @param \SimpleSAML\XMLSchema\XML\Interface\TypeDefParticleInterface|null $particle |
32
|
|
|
* @param ( |
33
|
|
|
* \SimpleSAML\XMLSchema\XML\LocalAttribute| |
34
|
|
|
* \SimpleSAML\XMLSchema\XML\ReferencedAttributeGroup |
35
|
|
|
* )[] $attributes |
36
|
|
|
* @param \SimpleSAML\XMLSchema\XML\AnyAttribute|null $anyAttribute |
37
|
|
|
* @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation |
38
|
|
|
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $id |
39
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
40
|
|
|
*/ |
41
|
|
|
public function __construct( |
42
|
|
|
protected QNameValue $base, |
43
|
|
|
// xs:typeDefParticle |
44
|
|
|
?TypeDefParticleInterface $particle = null, |
45
|
|
|
// xs:attrDecls |
46
|
|
|
array $attributes = [], |
47
|
|
|
?AnyAttribute $anyAttribute = null, |
48
|
|
|
// parent defined |
49
|
|
|
?Annotation $annotation = null, |
50
|
|
|
?IDValue $id = null, |
51
|
|
|
array $namespacedAttributes = [], |
52
|
|
|
) { |
53
|
|
|
parent::__construct($annotation, $id, $namespacedAttributes); |
54
|
|
|
|
55
|
|
|
$this->setAttributes($attributes); |
56
|
|
|
$this->setAnyAttribute($anyAttribute); |
57
|
|
|
$this->setParticle($particle); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Collect the value of the base-property |
63
|
|
|
* |
64
|
|
|
* @return \SimpleSAML\XMLSchema\Type\QNameValue |
65
|
|
|
*/ |
66
|
|
|
public function getBase(): ?QNameValue |
67
|
|
|
{ |
68
|
|
|
return $this->base; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Add this ExtensionType to an XML element. |
74
|
|
|
* |
75
|
|
|
* @param \DOMElement|null $parent The element we should append this ExtensionType to. |
76
|
|
|
* @return \DOMElement |
77
|
|
|
*/ |
78
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
79
|
|
|
{ |
80
|
|
|
$e = parent::toXML($parent); |
81
|
|
|
|
82
|
|
|
if ($this->getBase() !== null) { |
83
|
|
|
$e->setAttribute('base', strval($this->getBase())); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$this->getParticle()?->toXML($e); |
87
|
|
|
|
88
|
|
|
foreach ($this->getAttributes() as $attr) { |
89
|
|
|
$attr->toXML($e); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
$this->getAnyAttribute()?->toXML($e); |
93
|
|
|
|
94
|
|
|
return $e; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|