Add an command wrapper to allow easier loading and escaping of the actual commands.

This commit is contained in:
Gordon Heydon
2018-03-08 22:57:27 +11:00
parent 1a94e483fe
commit 9e35a8ab4d

View File

@@ -23,6 +23,8 @@ class Execute extends Base
*/ */
protected $container; protected $container;
protected $commandWrapper;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@@ -42,6 +44,11 @@ class Execute extends Base
return $this; return $this;
} }
public function setCommandWrapper($command) {
$this->commandWrapper = $command;
return $this;
}
/** /**
* Set execute command. * Set execute command.
* *
@@ -148,6 +155,15 @@ class Execute extends Base
*/ */
public function getCommand() public function getCommand()
{ {
return parent::getCommand() . " {$this->container} {$this->command}"; $this->arg($this->container);
if (isset($this->commandWrapper)) {
$command = $this->commandWrapper . ' ' . self::escape($this->command);
}
else {
$command = $this->command;
}
return parent::getCommand() . " {$command}";
} }
} }