Skip to content

Commit

Permalink
ENH Do not show icon if binary is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Nov 29, 2022
1 parent 69fa81a commit 215207b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Extensions/PdfExportExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use SilverStripe\Control\Director;
use SilverStripe\ORM\DataExtension;
use SilverStripe\Versioned\Versioned;
use SilverStripe\Dev\Deprecation;
use SilverStripe\Core\Environment;

class PdfExportExtension extends DataExtension
{
Expand Down Expand Up @@ -68,6 +70,22 @@ public function PdfLink()
return false;
}

$binaryPath = $this->owner->config()->get('wkhtmltopdf_binary');
if ($binaryPath) {
Deprecation::notice('3.0', 'wkhtmltopdf_binary config is deprecated. '.
'Use WKHTMLTOPDF_BINARY env var instead.');
}
if (!$binaryPath || !is_executable($binaryPath ?? '')) {
if (Environment::getEnv('WKHTMLTOPDF_BINARY')
&& is_executable(Environment::getEnv('WKHTMLTOPDF_BINARY') ?? '')
) {
$binaryPath = Environment::getEnv('WKHTMLTOPDF_BINARY');
}
}
if (!$binaryPath) {
return false;
}

$path = $this->getPdfFilename();

if ((Versioned::get_stage() === Versioned::LIVE) && file_exists($path ?? '')) {
Expand Down

0 comments on commit 215207b

Please sign in to comment.