function BatchBuilder::setFile

Same name in other branches
  1. 9 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setFile()
  2. 10 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setFile()
  3. 11.x 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_get_path(). 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 217

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.