aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Background/JobWorker.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2025-03-31 18:07:57 +0200
committerJulius Knorr <jus@bitgrid.net>2025-04-09 14:50:15 +0200
commit69b6c2811d7d9f5f27c9e9fc8bae740105dc1c16 (patch)
tree648c030ee4fc6b73a4e756390c32c7a272cb9b7e /core/Command/Background/JobWorker.php
parentb82245ddea2db5bf1f2211199811454a5dbc0ee1 (diff)
downloadnextcloud-server-feat/cron/before-after-events.tar.gz
nextcloud-server-feat/cron/before-after-events.zip
feat(cron): Emit event before/after background job executionfeat/cron/before-after-events
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/Command/Background/JobWorker.php')
-rw-r--r--core/Command/Background/JobWorker.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/Command/Background/JobWorker.php b/core/Command/Background/JobWorker.php
index 8289021887b..401868c93ba 100644
--- a/core/Command/Background/JobWorker.php
+++ b/core/Command/Background/JobWorker.php
@@ -10,7 +10,10 @@ namespace OC\Core\Command\Background;
use OC\Core\Command\InterruptedException;
use OC\Files\SetupManager;
+use OCP\BackgroundJob\Events\BeforeJobExecutedEvent;
+use OCP\BackgroundJob\Events\JobExecutedEvent;
use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\ITempManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Input\InputArgument;
@@ -25,6 +28,7 @@ class JobWorker extends JobBase {
protected LoggerInterface $logger,
private ITempManager $tempManager,
private SetupManager $setupManager,
+ private IEventDispatcher $eventDispatcher,
) {
parent::__construct($jobList, $logger);
}
@@ -125,8 +129,10 @@ class JobWorker extends JobBase {
$this->printJobInfo($job->getId(), $job, $output);
}
+ $this->eventDispatcher->dispatchTyped(new BeforeJobExecutedEvent($job));
/** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */
$job->execute($this->jobList);
+ $this->eventDispatcher->dispatchTyped(new JobExecutedEvent($job));
$output->writeln('Job ' . $job->getId() . ' has finished', OutputInterface::VERBOSITY_VERBOSE);