Skip to content
Browse files

do not force user to provide simplexmlelement in link

  • Loading branch information...
1 parent 14ebb27 commit 490948cbca1ae5f6a2ebe22090818470cd8618d7 @cweiske cweiske committed Feb 5, 2012
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/XML/XRD/Element/Link.php
View
16 src/XML/XRD/Element/Link.php
@@ -70,7 +70,21 @@ class XML_XRD_Element_Link extends XML_XRD_PropertyAccess
*
* @param object $x SimpleXMLElement representing the <Link>
*/
- public function __construct(SimpleXMLElement $x)
+ public function __construct(SimpleXMLElement $x = null)
+ {
+ if ($x) {
+ $this->loadFromSimpleXml($x);
+ }
+ }
+
+ /**
+ * Loads data from a SimpleXMLElement into the object.
+ *
+ * @param object $x SimpleXMLElement representing the <Link>
+ *
+ * @return void
+ */
+ protected function loadFromSimpleXml(SimpleXMLElement $x)
{
foreach (array('rel', 'type', 'href', 'template') as $var) {
if (isset($x[$var])) {

0 comments on commit 490948c

Please sign in to comment.
Something went wrong with that request. Please try again.