execute() public méthode

Run a shell command, suppressing errors.
public execute ( array $args, string | false $dir = null, boolean $mustRun = false, boolean $quiet = false ) : string | boolean
$args array
$dir string | false
$mustRun boolean
$quiet boolean
Résultat string | boolean The command's output or true on success, false on failure.
 /**
  * Execute a Git command.
  *
  * @param string[]     $args
  *   Command arguments (everything after 'git').
  * @param string|false $dir
  *   The path to a Git repository. Set to false if the command should not
  *   run inside a repository.
  * @param bool         $mustRun
  *   Enable exceptions if the Git command fails.
  * @param bool         $quiet
  *   Suppress command output.
  *
  * @throws \RuntimeException If the repository directory is invalid.
  *
  * @return string|bool
  */
 public function execute(array $args, $dir = null, $mustRun = false, $quiet = true)
 {
     // If enabled, set the working directory to the repository.
     if ($dir !== false) {
         $dir = $dir ?: $this->repositoryDir;
     }
     // Run the command.
     array_unshift($args, 'git');
     return $this->shellHelper->execute($args, $dir, $mustRun, $quiet);
 }
 /**
  * Extract a gzipped tar archive into the specified destination directory.
  *
  * @param string $archive
  * @param string $destination
  */
 public function extractArchive($archive, $destination)
 {
     if (!file_exists($archive)) {
         throw new \InvalidArgumentException("Archive not found: {$archive}");
     }
     if (!file_exists($destination) && !mkdir($destination, 0755, true)) {
         throw new \InvalidArgumentException("Could not create destination directory: {$destination}");
     }
     $tar = $this->getTarExecutable();
     $destination = $this->fixTarPath($destination);
     $archive = $this->fixTarPath($archive);
     $this->shellHelper->execute([$tar, '-xzp', '-C' . $destination, '-f' . $archive], null, true);
 }
 /**
  * Extract a gzipped tar archive into the specified destination directory.
  *
  * @param string $archive
  * @param string $destination
  */
 public function extractArchive($archive, $destination)
 {
     if (!file_exists($archive)) {
         throw new \InvalidArgumentException("Archive not found: {$archive}");
     }
     if (!is_writable(dirname($destination))) {
         throw new \InvalidArgumentException("Destination not writable: {$destination}");
     }
     $tar = $this->getTarExecutable();
     if (!file_exists($destination)) {
         mkdir($destination);
     }
     $destination = $this->fixTarPath($destination);
     $archive = $this->fixTarPath($archive);
     $this->shellHelper->execute([$tar, '-xzp', '-C' . $destination, '-f' . $archive], null, true);
 }
 /**
  * Execute a Drush command.
  *
  * @param string[] $args
  *   Command arguments (everything after 'drush').
  * @param string   $dir
  *   The working directory.
  * @param bool     $mustRun
  *   Enable exceptions if the command fails.
  * @param bool     $quiet
  *   Suppress command output.
  *
  * @return string|bool
  */
 public function execute(array $args, $dir = null, $mustRun = false, $quiet = true)
 {
     array_unshift($args, $this->getDrushExecutable());
     return $this->shellHelper->execute($args, $dir, $mustRun, $quiet);
 }