ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SAML2\XML\md\ContactPerson Class Reference
+ Collaboration diagram for SAML2\XML\md\ContactPerson:

Public Member Functions

 __construct (\DOMElement $xml=null)
 Initialize a ContactPerson element. More...
 
 toXML (\DOMElement $parent)
 Convert this ContactPerson to XML. More...
 

Data Fields

 $contactType
 
 $Extensions = array()
 
 $Company = null
 
 $GivenName = null
 
 $SurName = null
 
 $EmailAddress = array()
 
 $TelephoneNumber = array()
 
 $ContactPersonAttributes = array()
 

Static Private Member Functions

static getStringElements (\DOMElement $parent, $name)
 Retrieve the value of a child \DOMElements as an array of strings. More...
 
static getStringElement (\DOMElement $parent, $name)
 Retrieve the value of a child \DOMElement as a string. More...
 

Detailed Description

Definition at line 13 of file ContactPerson.php.

Constructor & Destructor Documentation

◆ __construct()

SAML2\XML\md\ContactPerson::__construct ( \DOMElement  $xml = null)

Initialize a ContactPerson element.

Parameters
\DOMElement | null$xmlThe XML element we should load.
Exceptions

Exception

Definition at line 79 of file ContactPerson.php.

80 {
81 if ($xml === null) {
82 return;
83 }
84
85 if (!$xml->hasAttribute('contactType')) {
86 throw new \Exception('Missing contactType on ContactPerson.');
87 }
88 $this->contactType = $xml->getAttribute('contactType');
89
90 $this->Extensions = Extensions::getList($xml);
91
92 $this->Company = self::getStringElement($xml, 'Company');
93 $this->GivenName = self::getStringElement($xml, 'GivenName');
94 $this->SurName = self::getStringElement($xml, 'SurName');
95 $this->EmailAddress = self::getStringElements($xml, 'EmailAddress');
96 $this->TelephoneNumber = self::getStringElements($xml, 'TelephoneNumber');
97
98 foreach ($xml->attributes as $attr) {
99 if ($attr->nodeName == "contactType") {
100 continue;
101 }
102
103 $this->ContactPersonAttributes[$attr->nodeName] = $attr->nodeValue;
104 }
105 }
static getStringElement(\DOMElement $parent, $name)
Retrieve the value of a child \DOMElement as a string.
static getStringElements(\DOMElement $parent, $name)
Retrieve the value of a child \DOMElements as an array of strings.
static getList(\DOMElement $parent)
Get a list of Extensions in the given element.
Definition: Extensions.php:27

References $xml, SAML2\XML\md\Extensions\getList(), SAML2\XML\md\ContactPerson\getStringElement(), and SAML2\XML\md\ContactPerson\getStringElements().

+ Here is the call graph for this function:

Member Function Documentation

◆ getStringElement()

static SAML2\XML\md\ContactPerson::getStringElement ( \DOMElement  $parent,
  $name 
)
staticprivate

Retrieve the value of a child \DOMElement as a string.

Parameters
\DOMElement$parentThe parent element.
string$nameThe name of the child element.
Returns
string|null The value of the child element.
Exceptions

Exception

Definition at line 136 of file ContactPerson.php.

137 {
138 assert(is_string($name));
139
140 $e = self::getStringElements($parent, $name);
141 if (empty($e)) {
142 return null;
143 }
144 if (count($e) > 1) {
145 throw new \Exception('More than one ' . $name . ' in ' . $parent->tagName);
146 }
147
148 return $e[0];
149 }

References $name, and SAML2\XML\md\ContactPerson\getStringElements().

Referenced by SAML2\XML\md\ContactPerson\__construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStringElements()

static SAML2\XML\md\ContactPerson::getStringElements ( \DOMElement  $parent,
  $name 
)
staticprivate

Retrieve the value of a child \DOMElements as an array of strings.

Parameters
\DOMElement$parentThe parent element.
string$nameThe name of the child elements.
Returns
array The value of the child elements.

Definition at line 114 of file ContactPerson.php.

115 {
116 assert(is_string($name));
117
118 $e = Utils::xpQuery($parent, './saml_metadata:' . $name);
119
120 $ret = array();
121 foreach ($e as $i) {
122 $ret[] = $i->textContent;
123 }
124
125 return $ret;
126 }
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
$i
Definition: disco.tpl.php:19
$ret
Definition: parser.php:6

References $i, $name, $ret, and SAML2\Utils\xpQuery().

Referenced by SAML2\XML\md\ContactPerson\__construct(), and SAML2\XML\md\ContactPerson\getStringElement().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

SAML2\XML\md\ContactPerson::toXML ( \DOMElement  $parent)

Convert this ContactPerson to XML.

Parameters
\DOMElement$parentThe element we should add this contact to.
Returns
\DOMElement The new ContactPerson-element.

Definition at line 157 of file ContactPerson.php.

158 {
159 assert(is_string($this->contactType));
160 assert(is_array($this->Extensions));
161 assert(is_null($this->Company) || is_string($this->Company));
162 assert(is_null($this->GivenName) || is_string($this->GivenName));
163 assert(is_null($this->SurName) || is_string($this->SurName));
164 assert(is_array($this->EmailAddress));
165 assert(is_array($this->TelephoneNumber));
166 assert(is_array($this->ContactPersonAttributes));
167
168 $doc = $parent->ownerDocument;
169
170 $e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
171 $parent->appendChild($e);
172
173 $e->setAttribute('contactType', $this->contactType);
174
175 foreach ($this->ContactPersonAttributes as $attr => $val) {
176 $e->setAttribute($attr, $val);
177 }
178
179 Extensions::addList($e, $this->Extensions);
180
181 if (isset($this->Company)) {
182 Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
183 }
184 if (isset($this->GivenName)) {
185 Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
186 }
187 if (isset($this->SurName)) {
188 Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
189 }
190 if (!empty($this->EmailAddress)) {
191 Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->EmailAddress);
192 }
193 if (!empty($this->TelephoneNumber)) {
194 Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->TelephoneNumber);
195 }
196
197 return $e;
198 }
const NS_MD
The namespace for the SAML 2 metadata.
Definition: Constants.php:230
static addString(\DOMElement $parent, $namespace, $name, $value)
Append string element.
Definition: Utils.php:635
static addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
Append string elements.
Definition: Utils.php:659
static addList(\DOMElement $parent, array $extensions)
Add a list of Extensions to the given element.
Definition: Extensions.php:70

References SAML2\XML\md\Extensions\addList(), SAML2\Utils\addString(), SAML2\Utils\addStrings(), and SAML2\Constants\NS_MD.

+ Here is the call graph for this function:

Field Documentation

◆ $Company

SAML2\XML\md\ContactPerson::$Company = null

Definition at line 36 of file ContactPerson.php.

◆ $ContactPersonAttributes

SAML2\XML\md\ContactPerson::$ContactPersonAttributes = array()

Definition at line 71 of file ContactPerson.php.

◆ $contactType

SAML2\XML\md\ContactPerson::$contactType

Definition at line 20 of file ContactPerson.php.

◆ $EmailAddress

SAML2\XML\md\ContactPerson::$EmailAddress = array()

Definition at line 57 of file ContactPerson.php.

◆ $Extensions

SAML2\XML\md\ContactPerson::$Extensions = array()

Definition at line 29 of file ContactPerson.php.

◆ $GivenName

SAML2\XML\md\ContactPerson::$GivenName = null

Definition at line 43 of file ContactPerson.php.

◆ $SurName

SAML2\XML\md\ContactPerson::$SurName = null

Definition at line 50 of file ContactPerson.php.

◆ $TelephoneNumber

SAML2\XML\md\ContactPerson::$TelephoneNumber = array()

Definition at line 64 of file ContactPerson.php.


The documentation for this class was generated from the following file: