You are here

public function BatchBuilder::setFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setFile()
  2. 9 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setFile()

Sets the file that contains the callback functions.

The path should be relative to base_path(), and thus should be built using \Drupal\Core\Extension\ExtensionList::getPath(). Defaults to {module_name}.module.

The file needs to be set before using ::addOperation(), ::setFinishCallback(), or any other function that uses callbacks from the file. This is so that PHP knows about the included functions.

Parameters

string $filename: The path to the file.

Return value

$this

File

core/lib/Drupal/Core/Batch/BatchBuilder.php, line 218

Class

BatchBuilder
Builds an array for a batch process.

Namespace

Drupal\Core\Batch

Code

public function setFile($filename) {
  include_once $filename;
  $this->file = $filename;
  return $this;
}