From 67a0a97f9a818facea8c162d2bccccbe723af1a5 Mon Sep 17 00:00:00 2001 From: Radu Liviu Carjan Date: Mon, 31 Oct 2022 08:27:26 +0200 Subject: [PATCH] Minor update to the convertor class --- app/SearchDisplace/Convertor/Convertor.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/SearchDisplace/Convertor/Convertor.php b/app/SearchDisplace/Convertor/Convertor.php index 763a46a..1b965ce 100644 --- a/app/SearchDisplace/Convertor/Convertor.php +++ b/app/SearchDisplace/Convertor/Convertor.php @@ -35,7 +35,7 @@ class Convertor { ]; if ($extension == 'odt') { - $to = $to . ':"$FILTER"'; + $to = $to . ':"${:FILTER}"'; $env['FILTER'] = 'OpenDocument Text Flat XML'; } @@ -65,14 +65,21 @@ class Convertor { // 'FILTER' => 'OpenDocument Text Flat XML' // ] // ); + # We will run the process from a shell command line, which allows us to add parameters + # The "OpenDocument Text Flat XML" parameter contains whitespaces, so we will need to add that as + # a env variable parameter, otherwise the Process class will escape it and it will not work properly. $process = Process::fromShellCommandline( "soffice --convert-to $to $original --outdir $folder", base_path(), $env ); - $process->run(null, $env); - - Log::info("OUTPUT: " . $process->getOutput()); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + Log::info("CONVERT ERROR: " . $buffer); + } else { + // Log::info("CONVERT OUTPUT: " . $buffer); + } + }, $env); if (!$process->isSuccessful()) { throw new ProcessFailedException($process);