I need to process a parameter in a batch function where the result will be kept after the function ends and it should be then passed in the finished function of the same batch. Is there a way to pass the parameters by a reference, so that any changes to that parameter are saved?
Example:
$params = [$a, $b];
$finishedParams = [$a, $b];
$batch = ['title' => 'Sample processing batch',
'operations' => ['someFunction', $params],
'finished' => ['finishedFunction', $finishedParams]
];
...
public static function someFunction(&$a, $b){
$a = 'somethingChanged';
}
public static function finishedFunction($success, $results, $operations){
// Use $a variable when somethingChanged after the batch process.
}