Create MicroweberShellExecutor.php

This commit is contained in:
Bozhidar 2024-05-10 18:25:08 +03:00
parent 928fee3f0d
commit 38ada71ca7

View file

@ -0,0 +1,23 @@
<?php
namespace Modules\Microweber;
use MicroweberPackages\SharedServerScripts\Shell\Adapters\NativeShellExecutor;
use Symfony\Component\Process\Process;
class MicroweberShellExecutor extends NativeShellExecutor
{
public function executeCommand(array $args, $cwd = null, $env = null)
{
// Escape shell arguments
$args = array_map('escapeshellarg', $args);
$command = implode(' ', $args);
if (!empty($cwd)) {
$command = 'cd ' . escapeshellarg($cwd) . ' && ' . $command;
}
return shell_exec($command);
}
}