You are here

protected function ProcessTrait::runCommand in Tome 8

Runs a single command and outputs errors if encountered.

Parameters

string|array $command: The command to run.

string $cwd: (Optional) The working directory to use.

int|float|null $timeout: The timeout in seconds or null to disable.

Return value

bool Whether or not the process executed successfully.

5 calls to ProcessTrait::runCommand()
ExportCommand::execute in modules/tome_sync/src/Commands/ExportCommand.php
ImportCommand::execute in modules/tome_sync/src/Commands/ImportCommand.php
ImportPartialCommand::execute in modules/tome_sync/src/Commands/ImportPartialCommand.php
StaticCommand::execute in modules/tome_static/src/Commands/StaticCommand.php
StaticPreviewCommand::execute in modules/tome_static/src/Commands/StaticPreviewCommand.php

File

modules/tome_base/src/ProcessTrait.php, line 92

Class

ProcessTrait
Shared methods for running processes.

Namespace

Drupal\tome_base

Code

protected function runCommand($command, $cwd = NULL, $timeout = 60) {
  $process = new Process($command, $cwd, NULL, NULL, $timeout);
  $process
    ->run();
  $successful = $process
    ->isSuccessful();
  $errors = [];
  if (!$successful) {
    $errors[] = "Error when running \"{$command}\"";
    if ($error_output = $process
      ->getErrorOutput()) {
      $errors[] = $error_output;
    }
    $this
      ->displayErrors($errors);
  }
  return $successful;
}