function _tome_static_cron_queue_paths in Tome 8
Enqueues paths for static generation.
Paths passed to this function should have already been passed to the tome_static.generator service's exportPaths method.
@internal
Parameters
array $paths: An array of paths to queue.
string $base_url: The base URL.
3 calls to _tome_static_cron_queue_paths()
- TomeStaticCronTest::testStaticCron in modules/
tome_static/ modules/ tome_static_cron/ tests/ src/ Functional/ TomeStaticCronTest.php - Tests the static cron.
- TomeStaticQueueWorker::processItem in modules/
tome_static/ modules/ tome_static_cron/ src/ Plugin/ QueueWorker/ TomeStaticQueueWorker.php - Works on a single queue item.
- tome_static_cron_cron in modules/
tome_static/ modules/ tome_static_cron/ tome_static_cron.module - Implements hook_cron().
File
- modules/
tome_static/ modules/ tome_static_cron/ tome_static_cron.module, line 56 - Contains hook implementations for the tome_static_cron module.
Code
function _tome_static_cron_queue_paths(array $paths, $base_url) {
$old_paths = \Drupal::state()
->get(TomeStaticQueueWorker::STATE_KEY_OLD_PATHS, []);
$paths = array_diff($paths, $old_paths);
if (!empty($paths)) {
$queue = \Drupal::queue('tome_static_cron');
foreach ($paths as $path) {
$queue
->createItem([
'path' => $path,
'base_url' => $base_url,
]);
}
$queue
->createItem([
'action' => 'process_invoke_paths',
'base_url' => $base_url,
]);
$old_paths = array_merge($paths, $old_paths);
}
\Drupal::state()
->set(TomeStaticQueueWorker::STATE_KEY_OLD_PATHS, $old_paths);
}