public static function buildPhpCommand(array $settings)
{
$subRequestEnvironmentVariables = ['FLOW_ROOTPATH' => FLOW_PATH_ROOT, 'FLOW_PATH_TEMPORARY_BASE' => FLOW_PATH_TEMPORARY_BASE, 'FLOW_CONTEXT' => $settings['core']['context']];
if (isset($settings['core']['subRequestEnvironmentVariables'])) {
$subRequestEnvironmentVariables = array_merge($subRequestEnvironmentVariables, $settings['core']['subRequestEnvironmentVariables']);
}
$command = '';
foreach ($subRequestEnvironmentVariables as $argumentKey => $argumentValue) {
if (DIRECTORY_SEPARATOR === '/') {
$command .= sprintf('%s=%s ', $argumentKey, escapeshellarg($argumentValue));
} else {
// SET does not parse out quotes, hence we need escapeshellcmd here instead
$command .= sprintf('SET %s=%s&', $argumentKey, escapeshellcmd($argumentValue));
}
}
if (DIRECTORY_SEPARATOR === '/') {
$phpBinaryPathAndFilename = '"' . escapeshellcmd(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"';
} else {
$phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename']));
}
$command .= $phpBinaryPathAndFilename;
if (!isset($settings['core']['subRequestPhpIniPathAndFilename']) || $settings['core']['subRequestPhpIniPathAndFilename'] !== false) {
if (!isset($settings['core']['subRequestPhpIniPathAndFilename'])) {
$useIniFile = php_ini_loaded_file();
} else {
$useIniFile = $settings['core']['subRequestPhpIniPathAndFilename'];
}
$command .= ' -c ' . escapeshellarg($useIniFile);
}
return $command;
}