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\Schema\NamespaceListValue; |
10
|
|
|
use SimpleSAML\XMLSchema\Type\Schema\ProcessContentsValue; |
11
|
|
|
|
12
|
|
|
use function strval; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Abstract class representing the wildcard-type. |
16
|
|
|
* |
17
|
|
|
* @package simplesamlphp/xml-common |
18
|
|
|
*/ |
19
|
|
|
abstract class AbstractWildcard extends AbstractAnnotated |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* Wildcard constructor |
23
|
|
|
* |
24
|
|
|
* @param \SimpleSAML\XMLSchema\Type\Schema\NamespaceListValue|null $namespace |
25
|
|
|
* @param \SimpleSAML\XMLSchema\Type\Schema\ProcessContentsValue|null $processContents |
26
|
|
|
* @param \SimpleSAML\XMLSchema\XML\Annotation|null $annotation |
27
|
|
|
* @param \SimpleSAML\XMLSchema\Type\IDValue|null $id |
28
|
|
|
* @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes |
29
|
|
|
*/ |
30
|
|
|
public function __construct( |
31
|
|
|
protected ?NamespaceListValue $namespace = null, |
32
|
|
|
protected ?ProcessContentsValue $processContents = null, |
33
|
|
|
?Annotation $annotation = null, |
34
|
|
|
?IDValue $id = null, |
35
|
|
|
array $namespacedAttributes = [], |
36
|
|
|
) { |
37
|
|
|
parent::__construct($annotation, $id, $namespacedAttributes); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Collect the value of the namespace-property |
43
|
|
|
* |
44
|
|
|
* @return \SimpleSAML\XMLSchema\Type\Schema\NamespaceListValue|null |
45
|
|
|
*/ |
46
|
|
|
public function getNamespace(): ?NamespaceListValue |
47
|
|
|
{ |
48
|
|
|
return $this->namespace; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Collect the value of the processContents-property |
54
|
|
|
* |
55
|
|
|
* @return \SimpleSAML\XMLSchema\Type\Schema\ProcessContentsValue|null |
56
|
|
|
*/ |
57
|
|
|
public function getProcessContents(): ?ProcessContentsValue |
58
|
|
|
{ |
59
|
|
|
return $this->processContents; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Test if an object, at the state it's in, would produce an empty XML-element |
65
|
|
|
* |
66
|
|
|
* @return bool |
67
|
|
|
*/ |
68
|
|
|
public function isEmptyElement(): bool |
69
|
|
|
{ |
70
|
|
|
return parent::isEmptyElement() && |
71
|
|
|
empty($this->getNamespace()) && |
72
|
|
|
empty($this->getProcessContents()); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Add this Wildcard to an XML element. |
78
|
|
|
* |
79
|
|
|
* @param \DOMElement|null $parent The element we should append this Wildcard to. |
80
|
|
|
* @return \DOMElement |
81
|
|
|
*/ |
82
|
|
|
public function toXML(?DOMElement $parent = null): DOMElement |
83
|
|
|
{ |
84
|
|
|
$e = parent::toXML($parent); |
85
|
|
|
|
86
|
|
|
if ($this->getNamespace() !== null) { |
87
|
|
|
$e->setAttribute('namespace', strval($this->getNamespace())); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
if ($this->getProcessContents() !== null) { |
91
|
|
|
$e->setAttribute('processContents', strval($this->getProcessContents())); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
return $e; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|