Skip to content

Commit

Permalink
Merge pull request #12 from vyacheslav-startsev/add-env-parameter
Browse files Browse the repository at this point in the history
Added env parameter for Process
  • Loading branch information
mnvx authored Jun 4, 2020
2 parents 3a827f8 + 7b76e2e commit fc4c1a6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ class Converter implements ConverterInterface
*/
protected $tempPrefix;

/**
* The environment variables or null to use the same environment as the current PHP process
* @var array|null
*/
protected $env;

/**
* Defailt options for libreoffice
* @var array
Expand All @@ -53,18 +59,21 @@ class Converter implements ConverterInterface

/**
* Converter constructor.
*
* @param string $binaryPath
* @param string $tempDir
* @param int $timeout
* @param LoggerInterface|null $logger
* @param string $tempPrefix
* @param array $env
*/
public function __construct(
/*string*/ $binaryPath = self::BINARY_DEFAULT,
/*string*/ $tempDir = null,
/*int*/ $timeout = null,
LoggerInterface $logger = null,
/*string*/ $tempPrefix = 'lowrapper_'
/*string*/ $tempPrefix = 'lowrapper_',
/*array*/ $env = null
) {
if (!$logger) {
$logger = new NullLogger();
Expand All @@ -79,6 +88,7 @@ public function __construct(

$this->timeout = $timeout;
$this->tempPrefix = $tempPrefix;
$this->env = $env;
}

/**
Expand Down Expand Up @@ -157,7 +167,7 @@ public function addOption($option)
*/
protected function createProcess(/*string*/ $command)//: Process
{
return new Process($command, $this->tempDir);
return new Process($command, $this->tempDir, $this->env);
}

/**
Expand Down Expand Up @@ -244,4 +254,4 @@ protected function deleteInput(LowrapperParameters $parameters, /*string*/ $inpu
unlink($inputFile);
}

}
}

0 comments on commit fc4c1a6

Please sign in to comment.