Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
guenbakku committed Jul 2, 2017
2 parents 9a770fe + 40331ca commit 27070b4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Pdf {
protected $pageContainer = '<div class="page-container">%s</div>';

public function __construct() {
$this->setBinary();
$this->_setBinary();
$this->Snappy = new \Knp\Snappy\Pdf($this->binary);
}

Expand Down Expand Up @@ -128,7 +128,7 @@ public function __call($name, $arguments) {
* @param string: path of current script
* @return string: path of root
*/
protected function findRoot($root) {
protected function _findRoot($root) {
do {
$lastRoot = $root;
$root = dirname($root);
Expand All @@ -148,19 +148,23 @@ protected function findRoot($root) {
* @param void
* @return string: path of binary
*/
protected function setBinary() {
protected function _setBinary() {
$is32bit = PHP_INT_SIZE === 4;
if ($is32bit) {
$binary = 'wkhtmltopdf-i386';
} else {
$binary = 'wkhtmltopdf-amd64';
}

$root = $this->findRoot(__FILE__);
$this->binary = implode(DIRECTORY_SEPARATOR, array(
$root = $this->_findRoot(__FILE__);
$binary = implode(DIRECTORY_SEPARATOR, array(
$root, $this->vendor, 'bin', $binary
));

if (is_file($binary) || is_link($binary)) {
$this->binary = $binary;
}

return $this->binary;
}
}

0 comments on commit 27070b4

Please sign in to comment.