Doctrine\OXM\Marshaller\XmlMarshaller::marshalToStream PHP Method

marshalToStream() public method

public marshalToStream ( object $mappedObject, string $streamUri ) : boolean | integer
$mappedObject object
$streamUri string
return boolean | integer
    public function marshalToStream($mappedObject, $streamUri)
    {
        $writer = new WriterHelper($this, $streamUri);
        // clear the internal visited list
        $this->visited = array();
        // Begin marshalling
        $this->doMarshal($mappedObject, $writer);
        return $writer->flush();
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function itShouldMarshalToFilenameStream()
 {
     $simple = new SimpleWithField();
     $xml = $this->marshaller->marshalToStream($simple, "file://" . realpath(__DIR__) . "/../Workspace/Foo.xml");
     $this->assertTrue(strlen($xml) > 0);
     $this->assertXmlStringEqualsXmlFile(realpath(__DIR__) . "/../Workspace/Foo.xml", '<?xml version="1.0" encoding="UTF-8"?><simple-with-field/>');
     @unlink(realpath(__DIR__) . "/../Workspace/Foo.xml");
 }
All Usage Examples Of Doctrine\OXM\Marshaller\XmlMarshaller::marshalToStream