diff options
author | Arron Woods <aw@chartblocks.com> | 2015-04-23 16:52:50 +0100 |
---|---|---|
committer | Arron Woods <aw@chartblocks.com> | 2015-04-23 16:52:58 +0100 |
commit | a12d873a6a8230dd2ef1255fedd5753068ce86ee (patch) | |
tree | 8b8cedba08b540689009861225b1108fc5b3460f /library/SSRS/Report | |
parent | 320d49f6af9fd66ab1ba72da22fd9fa37fcad0e4 (diff) | |
download | php-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.zip php-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.tar.gz php-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.tar.bz2 |
Cache streams from report output
Diffstat (limited to 'library/SSRS/Report')
-rw-r--r-- | library/SSRS/Report/CachedStreamResource.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/library/SSRS/Report/CachedStreamResource.php b/library/SSRS/Report/CachedStreamResource.php new file mode 100644 index 0000000..08e9dbb --- /dev/null +++ b/library/SSRS/Report/CachedStreamResource.php @@ -0,0 +1,43 @@ +<?php + +namespace SSRS\Report; + +use \SSRS\Object\RenderStream; + +class CachedStreamResource { + + public $streamId; + public $filePath; + + public function __construct($streamId, $filePath) { + $this->streamId = $streamId; + $this->filePath = $filePath; + } + + public function read() { + $data = file_get_contents($this->filePath); + $parts = explode("\n", $data, 2); + + $stream = new RenderStream(); + $stream->MimeType = $parts[0]; + $stream->Result = $parts[1]; + + return $stream; + } + + public function store(RenderStream $renderStream) { + $data = trim($renderStream->MimeType) . "\n"; + $data .= $renderStream->Result; + + file_put_contents($this->filePath, $data); + return $this; + } + + public function send() { + $stream = $this->read(); + + header('Content-Type: ' . $stream->MimeType); + echo $stream->Result; + } + +} |