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