You are here

public function SjLocalDevClient::addJob in Acquia Cloud Site Factory Connector 8.2

Same name and namespace in other branches
  1. 8 acsf_sj/src/Api/SjLocalDevClient.php \Drupal\acsf_sj\Api\SjLocalDevClient::addJob()

Adds a scheduled job.

Parameters

string $drush_command: A drush command to run.

string $reason: The purpose of this job.

int $timestamp: Unix timestamp when the command should be run or NULL to run ASAP.

string $domain: The domain to use when calling the drush command or NULL for the class to determine.

int $timeout: How long in seconds the process should be allowed to run or NULL for system default.

string $drush_executable: The drush binary to use, 'drush' by default. i.e. drush9.

string $drush_options: A list of drush options that will be applied to the drush command. If none are provided, "-y" will be used.

Return value

bool Returns TRUE on a non-zero exit code signaling that the sjadd command succeeded.

Overrides SjApiClient::addJob

File

acsf_sj/src/Api/SjLocalDevClient.php, line 15

Class

SjLocalDevClient
Provides a Scheduled Jobs API local development client.

Namespace

Drupal\acsf_sj\Api

Code

public function addJob($drush_command, $reason = NULL, $timestamp = NULL, $domain = NULL, $timeout = NULL, $drush_executable = NULL, $drush_options = NULL) {
  try {
    $this
      ->inputValidation($drush_command, $timestamp, $domain, $timeout, $drush_executable, $drush_options);
  } catch (\Exception $e) {
    $this->logger
      ->log(LogLevel::ERROR, 'Local dev: unable to add the scheduled job: @message', [
      '@message' => $e
        ->getMessage(),
    ]);
    return FALSE;
  }
  $sjadd_arguments = $this
    ->prepareCommandArguments($drush_command, $reason, $timestamp, $domain, $timeout, $drush_executable, $drush_options);
  $this->logger
    ->log(LogLevel::NOTICE, 'Local dev: sjadd @arguments', [
    '@arguments' => $sjadd_arguments,
  ]);
  return TRUE;
}