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

Public Member Functions

 __construct ($value)
 Create an AttributeValue. More...
 
 toXML (\DOMElement $parent)
 Append this attribute value to an element. More...
 
 getString ()
 Returns a plain text content of the attribute value. More...
 
 __toString ()
 Convert this attribute value to a string. More...
 
 serialize ()
 Serialize this AttributeValue. More...
 
 unserialize ($serialized)
 Un-serialize this AttributeValue. More...
 

Data Fields

 $element
 

Detailed Description

Definition at line 14 of file AttributeValue.php.

Constructor & Destructor Documentation

◆ __construct()

SAML2\XML\saml\AttributeValue::__construct (   $value)

Create an AttributeValue.

Parameters
mixed$valueThe value of this element. Can be one of:
  • string Create an attribute value with a simple string.
  • (AttributeValue) Create an attribute value of the given DOMElement.
  • Create an attribute value with the given DOMElement as a child.

Definition at line 31 of file AttributeValue.php.

References SAML2\DOMDocumentFactory\create(), SAML2\Constants\NS_SAML, SAML2\Constants\NS_XS, and SAML2\Constants\NS_XSI.

32  {
33  assert(is_string($value) || $value instanceof \DOMElement);
34 
35  if (is_string($value)) {
37  $this->element = $doc->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
38  $this->element->setAttributeNS(Constants::NS_XSI, 'xsi:type', 'xs:string');
39  $this->element->appendChild($doc->createTextNode($value));
40 
41  /* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
42  $this->element->setAttributeNS(Constants::NS_XS, 'xs:tmp', 'tmp');
43  $this->element->removeAttributeNS(Constants::NS_XS, 'tmp');
44 
45  return;
46  }
47 
48  if ($value->namespaceURI === Constants::NS_SAML && $value->localName === 'AttributeValue') {
49  $this->element = Utils::copyElement($value);
50 
51  return;
52  }
53 
55  $this->element = $doc->createElementNS(Constants::NS_SAML, 'saml:AttributeValue');
56  Utils::copyElement($value, $this->element);
57  }
const NS_XS
The namespace fox XML schema.
Definition: Constants.php:230
const NS_XSI
The namespace for XML schema instance.
Definition: Constants.php:235
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220
+ Here is the call graph for this function:

Member Function Documentation

◆ __toString()

SAML2\XML\saml\AttributeValue::__toString ( )

Convert this attribute value to a string.

If this element contains XML data, that data will be encoded as a string and returned.

Returns
string This attribute value.

Definition at line 90 of file AttributeValue.php.

References $ret.

91  {
92  assert($this->element instanceof \DOMElement);
93 
94  $doc = $this->element->ownerDocument;
95 
96  $ret = '';
97  foreach ($this->element->childNodes as $c) {
98  $ret .= $doc->saveXML($c);
99  }
100 
101  return $ret;
102  }
$ret
Definition: parser.php:6

◆ getString()

SAML2\XML\saml\AttributeValue::getString ( )

Returns a plain text content of the attribute value.

Definition at line 78 of file AttributeValue.php.

79  {
80  return $this->element->textContent;
81  }

◆ serialize()

SAML2\XML\saml\AttributeValue::serialize ( )

Serialize this AttributeValue.

Returns
string The AttributeValue serialized.

Definition at line 110 of file AttributeValue.php.

111  {
112  return serialize($this->element->ownerDocument->saveXML($this->element));
113  }
serialize()
Serialize this AttributeValue.

◆ toXML()

SAML2\XML\saml\AttributeValue::toXML ( \DOMElement  $parent)

Append this attribute value to an element.

Parameters
\DOMElement$parentThe element we should append this attribute value to.
Returns
The generated AttributeValue element.

Definition at line 65 of file AttributeValue.php.

References SAML2\Constants\NS_SAML.

66  {
67  assert($this->element instanceof \DOMElement);
68  assert($this->element->namespaceURI === \SAML2\Constants::NS_SAML && $this->element->localName === "AttributeValue");
69 
70  $v = Utils::copyElement($this->element, $parent);
71 
72  return $v;
73  }
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220

◆ unserialize()

SAML2\XML\saml\AttributeValue::unserialize (   $serialized)

Un-serialize this AttributeValue.

Parameters
string$serializedThe serialized AttributeValue.

Definition at line 121 of file AttributeValue.php.

References SAML2\DOMDocumentFactory\fromString().

122  {
123  $doc = DOMDocumentFactory::fromString(unserialize($serialized));
124  $this->element = $doc->documentElement;
125  }
unserialize($serialized)
Un-serialize this AttributeValue.
+ Here is the call graph for this function:

Field Documentation

◆ $element

SAML2\XML\saml\AttributeValue::$element

Definition at line 21 of file AttributeValue.php.


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