summaryrefslogtreecommitdiffstats
path: root/library/SSRS/Object/ReportOutput.php
diff options
context:
space:
mode:
authorArron Woods <aw@chartblocks.com>2015-04-23 16:52:50 +0100
committerArron Woods <aw@chartblocks.com>2015-04-23 16:52:58 +0100
commita12d873a6a8230dd2ef1255fedd5753068ce86ee (patch)
tree8b8cedba08b540689009861225b1108fc5b3460f /library/SSRS/Object/ReportOutput.php
parent320d49f6af9fd66ab1ba72da22fd9fa37fcad0e4 (diff)
downloadphp-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.zip
php-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.tar.gz
php-ssrs-a12d873a6a8230dd2ef1255fedd5753068ce86ee.tar.bz2
Cache streams from report output
Diffstat (limited to 'library/SSRS/Object/ReportOutput.php')
-rwxr-xr-xlibrary/SSRS/Object/ReportOutput.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/library/SSRS/Object/ReportOutput.php b/library/SSRS/Object/ReportOutput.php
index 0500525..ac17fe4 100755
--- a/library/SSRS/Object/ReportOutput.php
+++ b/library/SSRS/Object/ReportOutput.php
@@ -2,8 +2,26 @@
namespace SSRS\Object;
+use SSRS\Report;
+use SSRS\Report\CachedStreamResource;
+
class ReportOutput extends ObjectAbstract {
+ public function preCacheStreams(Report $report, $localCachePath, $format = 'HTML4.0') {
+ $this->verifyCachePath($localCachePath);
+
+ $rootPath = rtrim($localCachePath, '/');
+ foreach ($this->StreamIds->string as $streamId) {
+ $path = $rootPath . '/' . $streamId;
+ $stream = $report->renderStream($format, $streamId);
+
+ $cachedResource = new CachedStreamResource($streamId, $path);
+ $cachedResource->store($stream);
+ }
+
+ return $this;
+ }
+
public function download($filename) {
header("Cache-control: max-age=3600, must-revalidate");
header("Pragma: public");
@@ -22,4 +40,16 @@ class ReportOutput extends ObjectAbstract {
return (string) $this->Result;
}
+ protected function verifyCachePath($path) {
+ if (false === file_exists($path) || false === is_dir($path)) {
+ throw new \RuntimeException('Stream cache path does not exist');
+ }
+
+ if (false === is_writable($path)) {
+ throw new \RuntimeException('Stream cache path is not writeable');
+ }
+
+ return $this;
+ }
+
}