Skip to content

Commit

Permalink
Merge pull request #106 from johnkarpn/master
Browse files Browse the repository at this point in the history
Fix get CSS function
  • Loading branch information
kartik-v authored Apr 14, 2020
2 parents e513d17 + f4a72e3 commit 0426925
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,21 @@ public function getCss()
if (!empty($this->_css)) {
return $this->_css;
}
$css = '';
$cssFiles = is_array($this->cssFile) ? $this->cssFile : [$this->cssFile];
foreach($cssFiles as $cssFile) {
$cssFile = Yii::getAlias($cssFile);
if (!empty($cssFile) && file_exists($cssFile)) {
$css .= file_get_contents($cssFile);
} else {
throw new InvalidConfigException("CSS File not found: '{$cssFile}'.");
$this->_css = '';
if (!empty($this->cssFile)) {
$cssFiles = is_array($this->cssFile) ? $this->cssFile : [$this->cssFile];
foreach ($cssFiles as $cssFile) {
$cssFile = Yii::getAlias($cssFile);
if (!empty($cssFile) && file_exists($cssFile)) {
$this->_css .= file_get_contents($cssFile);
}
else {
throw new InvalidConfigException("CSS File not found: '{$cssFile}'.");
}
}
}
$css .= $this->cssInline;
return $css;
$this->_css .= $this->cssInline;
return $this->_css;
}

/**
Expand Down

0 comments on commit 0426925

Please sign in to comment.