public function BatchService::warmUpFileProcess in Image Style Warmer 8
Batch process callback.
Parameters
int $fid: Id of the file.
object $context: Context for operations.
File
- src/
BatchService.php, line 22
Class
- BatchService
- Class BatchService
Namespace
Drupal\image_style_warmerCode
public function warmUpFileProcess($fid, $count, &$context) {
/** @var \Drupal\image_style_warmer\ImageStylesWarmerInterface $image_styles_warmer */
$image_styles_warmer = \Drupal::service('image_style_warmer.warmer');
$file = File::load($fid);
$image_styles_warmer
->warmUp($file);
// Store some results for post-processing in the 'finished' callback.
// The contents of 'results' will be available as $results in the
// 'finished' function (in this example, batch_example_finished()).
$context['results'][] = $fid;
$i = count($context['results']);
// Optional message displayed under the progressbar.
$context['message'] = t('Warming up styles for file @fid (@i/@count)', [
'@fid' => $fid,
'@i' => $i,
'@count' => $count,
]);
}