Skip to content

Commit c2a944f

Browse files
committed
#6: Can't open affix or dictionary files for dictionary named "default".
Fixed for Symfony < 3.2
1 parent 54063f0 commit c2a944f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/ExternalSpeller.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ public function __construct($binaryPath)
7272
public function checkText(Source $source, array $languages)
7373
{
7474
$process = $this->createProcess($this->createArguments($source, $languages));
75-
$process->setEnv($this->createEnvVars($source, $languages));
75+
if (method_exists($process, 'inheritEnvironmentVariables')) {
76+
// Symfony 3.2+
77+
$process->setEnv($this->createEnvVars($source, $languages));
78+
} else {
79+
// Symfony < 3.2
80+
$process->setEnv(
81+
array_merge($process->getEnv(), $this->createEnvVars($source, $languages))
82+
);
83+
}
7684

7785
/** @noinspection PhpParamsInspection */
7886
$process->setInput($source->getAsString());
@@ -224,7 +232,13 @@ protected function createProcess($args = null)
224232
} catch (RuntimeException $e) {
225233
throw new ExternalProgramFailedException($command, $e->getMessage(), 0, $e);
226234
}
227-
$process->inheritEnvironmentVariables(true);
235+
if (method_exists($process, 'inheritEnvironmentVariables')) {
236+
// Symfony 3.2+
237+
$process->inheritEnvironmentVariables(true);
238+
} else {
239+
// Symfony < 3.2
240+
$process->setEnv(['LANG' => getenv('LANG')]);
241+
}
228242
$process->setTimeout($this->timeout);
229243

230244
return $process;

0 commit comments

Comments
 (0)