public function addObject($data, $objectId = null, $digestObject = false)
	{
		if (is_null($this->doc))
		{
			$this->createXmlStructure();
		}
		
		if (is_string($data) && strlen($data))
		{
			$data = $this->doc->createTextNode($data);
		}
		else if (!is_object($data) || !$data instanceof \DOMNode)
		{
			throw new \UnexpectedValueException(sprintf('Digested data must be a non-empty string or DOMNode, %s was given', gettype($data)));
		}
		
		// if the object is meant to be digested, do so
		if (true === $digestObject)
		{
			$digestedData = $this->calculateDigest($this->canonicalize($data));
			$data = $this->doc->createTextNode($digestedData);
		}
		else
		{
			$data = $this->doc->importNode($data, true);
		}
		
		// add the object to the dom
		$object = $this->doc->createElement($this->nodeNsPrefix . 'Object');
		$object->appendChild($data);
		$this->doc->getElementsByTagName('Signature')->item(0)->appendchild($object);
		
		// objects must have an id attribute which will
		// correspond to the reference URI attribute
		if (!is_string($objectId) || !strlen($objectId) || is_numeric($objectId[0]))
		{
			// generate a random ID
			$objectId = rtrim(base64_encode(mt_rand()), '=');
		}

		// if the ID was provided, add it
		$object->setAttribute('Id', $objectId);

		// objects also need to be digested and stored as references
		// so that they can be signed later
		$this->addReference($object, $objectId);
		
		return true;
	}
public function addObject($data, $objectId = null, $digestObject = false)
	{
		if (is_null($this->doc))
		{
			$this->createXmlStructure();
		}
		
		if (is_string($data) && strlen($data))
		{
			$data = $this->doc->createTextNode($data);
		}
		else if (!is_object($data) || !$data instanceof \DOMNode)
		{
			throw new \UnexpectedValueException(sprintf('Digested data must be a non-empty string or DOMNode, %s was given', gettype($data)));
		}
		
		// if the object is meant to be digested, do so
		if (true === $digestObject)
		{
			$digestedData = $this->calculateDigest($this->canonicalize($data));
			$data = $this->doc->createTextNode($digestedData);
		}
		else
		{
			$data = $this->doc->importNode($data, true);
		}
		
		// add the object to the dom
		$object = $this->doc->createElement($this->nodeNsPrefix . 'Object');
		$object->appendChild($data);
		$this->doc->getElementsByTagName('Signature')->item(0)->appendchild($object);
		
		// objects must have an id attribute which will
		// correspond to the reference URI attribute
		if (!is_string($objectId) || !strlen($objectId) || is_numeric($objectId[0]))
		{
			// generate a random ID
			$objectId = rtrim(base64_encode(mt_rand()), '=');
		}

		// if the ID was provided, add it
		$object->setAttribute('Id', $objectId);

		// objects also need to be digested and stored as references
		// so that they can be signed later
		$this->addReference($object, $objectId);
		
		return true;
	}
public function addObject ( $ data , $ objectId = null , $ digestObject = false ) { if ( is_null ( $ this -> doc ) ) { $ this -> createXmlStructure ( ) ; } if ( is_string ( $ data ) && strlen ( $ data ) ) { $ data = $ this -> doc -> createTextNode ( $ data ) ; } else if ( ! is_object ( $ data ) || ! $ data instanceof \ DOMNode ) { throw new \ UnexpectedValueException ( sprintf ( 'Digested data must be a non-empty string or DOMNode, %s was given' , gettype ( $ data ) ) ) ; } // if the object is meant to be digested, do so if ( true === $ digestObject ) { $ digestedData = $ this -> calculateDigest ( $ this -> canonicalize ( $ data ) ) ; $ data = $ this -> doc -> createTextNode ( $ digestedData ) ; } else { $ data = $ this -> doc -> importNode ( $ data , true ) ; } // add the object to the dom $ object = $ this -> doc -> createElement ( $ this -> nodeNsPrefix . 'Object' ) ; $ object -> appendChild ( $ data ) ; $ this -> doc -> getElementsByTagName ( 'Signature' ) -> item ( 0 ) -> appendchild ( $ object ) ; // objects must have an id attribute which will // correspond to the reference URI attribute if ( ! is_string ( $ objectId ) || ! strlen ( $ objectId ) || is_numeric ( $ objectId [ 0 ] ) ) { // generate a random ID $ objectId = rtrim ( base64_encode ( mt_rand ( ) ) , '=' ) ; } // if the ID was provided, add it $ object -> setAttribute ( 'Id' , $ objectId ) ; // objects also need to be digested and stored as references // so that they can be signed later $ this -> addReference ( $ object , $ objectId ) ; return true ; }
Appends an object to the signed XML documents

@param	DOMNode|string				$data			Data to add to the object node
@param	string						$objectId		ID attribute of the object
@param 	bool						$digestObject	Whether the object data should be digested
@throws	\UnexpectedValueException					If the canonicalization process failed
Appends an object to the signed XML documents