Added posibility to create "in memory" documents
Open writer with openToMemory(), then close it with closeAndGetStream() which will return the stream pointer. After that you have to do fclose() on that pointer.
This commit is contained in:
parent
e99c80b3ad
commit
e5c88e899c
@ -143,6 +143,33 @@ abstract class WriterAbstract implements WriterInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function openToMemory()
|
||||||
|
{
|
||||||
|
$this->filePointer = $this->globalFunctionsHelper->fopen('php://temp', 'r+');
|
||||||
|
$this->throwIfFilePointerIsNotAvailable();
|
||||||
|
|
||||||
|
$this->openWriter();
|
||||||
|
$this->isWriterOpened = true;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closeAndGetStream()
|
||||||
|
{
|
||||||
|
if (!$this->isWriterOpened) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->closeWriter();
|
||||||
|
|
||||||
|
$this->isWriterOpened = false;
|
||||||
|
|
||||||
|
rewind($this->filePointer);
|
||||||
|
fpassthru($this->filePointer);
|
||||||
|
|
||||||
|
return $this->filePointer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the pointer to the file/stream to write to is available.
|
* Checks if the pointer to the file/stream to write to is available.
|
||||||
* Will throw an exception if not available.
|
* Will throw an exception if not available.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user