aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Command/Background/Job.php6
-rw-r--r--core/Command/Background/JobWorker.php6
2 files changed, 12 insertions, 0 deletions
diff --git a/core/Command/Background/Job.php b/core/Command/Background/Job.php
index 7fa005cf231..5cea459f177 100644
--- a/core/Command/Background/Job.php
+++ b/core/Command/Background/Job.php
@@ -8,8 +8,11 @@ declare(strict_types=1);
namespace OC\Core\Command\Background;
+use OCP\BackgroundJob\Events\BeforeJobExecutedEvent;
+use OCP\BackgroundJob\Events\JobExecutedEvent;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\IEventDispatcher;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -19,6 +22,7 @@ use Symfony\Component\Console\Output\OutputInterface;
class Job extends Command {
public function __construct(
protected IJobList $jobList,
+ private IEventDispatcher $eventDispatcher,
) {
parent::__construct();
}
@@ -67,8 +71,10 @@ class Job extends Command {
$output->writeln('<error>Something went wrong when trying to retrieve Job with ID ' . $jobId . ' from database</error>');
return 1;
}
+ $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));
$job = $this->jobList->getById($jobId);
if (($job === null) || ($lastRun !== $job->getLastRun())) {
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);