ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SAML2\XML\mdui\Keywords Class Reference
+ Collaboration diagram for SAML2\XML\mdui\Keywords:

Public Member Functions

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

Data Fields

 $Keywords
 
 $lang
 

Detailed Description

Definition at line 11 of file Keywords.php.

Constructor & Destructor Documentation

◆ __construct()

SAML2\XML\mdui\Keywords::__construct ( \DOMElement  $xml = null)

Initialize a Keywords.

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

Exception

Definition at line 35 of file Keywords.php.

36 {
37 if ($xml === null) {
38 return;
39 }
40
41 if (!$xml->hasAttribute('xml:lang')) {
42 throw new \Exception('Missing lang on Keywords.');
43 }
44 if (!is_string($xml->textContent) || !strlen($xml->textContent)) {
45 throw new \Exception('Missing value for Keywords.');
46 }
47 $this->Keywords = array();
48 foreach (explode(' ', $xml->textContent) as $keyword) {
49 $this->Keywords[] = str_replace('+', ' ', $keyword);
50 }
51 $this->lang = $xml->getAttribute('xml:lang');
52 }
$xml
Definition: metadata.php:240

References $xml.

Member Function Documentation

◆ toXML()

SAML2\XML\mdui\Keywords::toXML ( \DOMElement  $parent)

Convert this Keywords to XML.

Parameters
\DOMElement$parentThe element we should append this Keywords to.
Returns
\DOMElement
Exceptions

Exception

Definition at line 61 of file Keywords.php.

62 {
63 assert(is_string($this->lang));
64 assert(is_array($this->Keywords));
65
66 $doc = $parent->ownerDocument;
67
68 $e = $doc->createElementNS(Common::NS, 'mdui:Keywords');
69 $e->setAttribute('xml:lang', $this->lang);
70 $value = '';
71 foreach ($this->Keywords as $keyword) {
72 if (strpos($keyword, "+") !== false) {
73 throw new \Exception('Keywords may not contain a "+" character.');
74 }
75 $value .= str_replace(' ', '+', $keyword) . ' ';
76 }
77 $value = rtrim($value);
78 $e->appendChild($doc->createTextNode($value));
79 $parent->appendChild($e);
80
81 return $e;
82 }

References SAML2\XML\mdui\Common\NS.

Field Documentation

◆ $Keywords

SAML2\XML\mdui\Keywords::$Keywords

Definition at line 20 of file Keywords.php.

◆ $lang

SAML2\XML\mdui\Keywords::$lang

Definition at line 27 of file Keywords.php.


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