You are here

public function BackgroundProcess::execute in Background Process 8

Same name and namespace in other branches
  1. 6 BackgroundProcess.class.php \BackgroundProcess::execute()
  2. 7.2 background_process.inc \BackgroundProcess::execute()
  3. 7 BackgroundProcess.class.php \BackgroundProcess::execute()

Implements Execute Process.

1 call to BackgroundProcess::execute()
BackgroundProcess::start in ./background_process.class.php
Implements to Call the service handler.

File

./background_process.class.php, line 153

Class

BackgroundProcess
BackgroundProcess class.

Code

public function execute($callback, $args = []) {
  $this->callback = $callback;
  $this->args = $args;
  if (!background_process_set_process($this->handle, $this->callback, $this->uid, $this->args, $this->token)) {

    // Could not update process.
    return NULL;
  }
  \Drupal::moduleHandler()
    ->invokeAll('background_process_pre_execute', [
    $this->handle,
    $this->callback,
    $this->args,
    $this->token,
  ]);

  // Initialize progress stats.
  $old_db = db_set_active('background_process');
  progress_remove_progress($this->handle);
  db_set_active($old_db);
  $this->connection = FALSE;
  $this
    ->determineServiceHost();
  return $this
    ->dispatch();
}