Skip to content

Commit 0426925

Browse files
authored
Merge pull request #106 from johnkarpn/master
Fix get CSS function
2 parents e513d17 + f4a72e3 commit 0426925

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/Pdf.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -306,18 +306,21 @@ public function getCss()
306306
if (!empty($this->_css)) {
307307
return $this->_css;
308308
}
309-
$css = '';
310-
$cssFiles = is_array($this->cssFile) ? $this->cssFile : [$this->cssFile];
311-
foreach($cssFiles as $cssFile) {
312-
$cssFile = Yii::getAlias($cssFile);
313-
if (!empty($cssFile) && file_exists($cssFile)) {
314-
$css .= file_get_contents($cssFile);
315-
} else {
316-
throw new InvalidConfigException("CSS File not found: '{$cssFile}'.");
309+
$this->_css = '';
310+
if (!empty($this->cssFile)) {
311+
$cssFiles = is_array($this->cssFile) ? $this->cssFile : [$this->cssFile];
312+
foreach ($cssFiles as $cssFile) {
313+
$cssFile = Yii::getAlias($cssFile);
314+
if (!empty($cssFile) && file_exists($cssFile)) {
315+
$this->_css .= file_get_contents($cssFile);
316+
}
317+
else {
318+
throw new InvalidConfigException("CSS File not found: '{$cssFile}'.");
319+
}
317320
}
318321
}
319-
$css .= $this->cssInline;
320-
return $css;
322+
$this->_css .= $this->cssInline;
323+
return $this->_css;
321324
}
322325

323326
/**

0 commit comments

Comments
 (0)