ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PublicationInfo.php
Go to the documentation of this file.
1<?php
2
3namespace SAML2\XML\mdrpi;
4
6
14{
20 public $publisher;
21
28
35
43 public $UsagePolicy = array();
44
51 public function __construct(\DOMElement $xml = null)
52 {
53 if ($xml === null) {
54 return;
55 }
56
57 if (!$xml->hasAttribute('publisher')) {
58 throw new \Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.');
59 }
60 $this->publisher = $xml->getAttribute('publisher');
61
62 if ($xml->hasAttribute('creationInstant')) {
63 $this->creationInstant = Utils::xsDateTimeToTimestamp($xml->getAttribute('creationInstant'));
64 }
65
66 if ($xml->hasAttribute('publicationId')) {
67 $this->publicationId = $xml->getAttribute('publicationId');
68 }
69
70 $this->UsagePolicy = Utils::extractLocalizedStrings($xml, Common::NS_MDRPI, 'UsagePolicy');
71 }
72
79 public function toXML(\DOMElement $parent)
80 {
81 assert(is_string($this->publisher));
82 assert(is_int($this->creationInstant) || is_null($this->creationInstant));
83 assert(is_string($this->publicationId) || is_null($this->publicationId));
84 assert(is_array($this->UsagePolicy));
85
86 $doc = $parent->ownerDocument;
87
88 $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:PublicationInfo');
89 $parent->appendChild($e);
90
91 $e->setAttribute('publisher', $this->publisher);
92
93 if ($this->creationInstant !== null) {
94 $e->setAttribute('creationInstant', gmdate('Y-m-d\TH:i:s\Z', $this->creationInstant));
95 }
96
97 if ($this->publicationId !== null) {
98 $e->setAttribute('publicationId', $this->publicationId);
99 }
100
101 Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:UsagePolicy', true, $this->UsagePolicy);
102
103 return $e;
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
static addStrings(\DOMElement $parent, $namespace, $name, $localized, array $values)
Append string elements.
Definition: Utils.php:659
static extractLocalizedStrings(\DOMElement $parent, $namespaceURI, $localName)
Extract localized strings from a set of nodes.
Definition: Utils.php:580
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp.
Definition: Utils.php:721
__construct(\DOMElement $xml=null)
Create/parse a mdrpi:PublicationInfo element.
toXML(\DOMElement $parent)
Convert this element to XML.