1010
1111use OC \Core \Command \InterruptedException ;
1212use OC \Files \SetupManager ;
13+ use OCP \BackgroundJob \Events \BeforeJobExecutedEvent ;
14+ use OCP \BackgroundJob \Events \JobExecutedEvent ;
1315use OCP \BackgroundJob \IJobList ;
16+ use OCP \EventDispatcher \IEventDispatcher ;
1417use OCP \ITempManager ;
1518use Psr \Log \LoggerInterface ;
1619use Symfony \Component \Console \Input \InputArgument ;
@@ -25,6 +28,7 @@ public function __construct(
2528 protected LoggerInterface $ logger ,
2629 private ITempManager $ tempManager ,
2730 private SetupManager $ setupManager ,
31+ private IEventDispatcher $ eventDispatcher ,
2832 ) {
2933 parent ::__construct ($ jobList , $ logger );
3034 }
@@ -125,8 +129,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
125129 $ this ->printJobInfo ($ job ->getId (), $ job , $ output );
126130 }
127131
132+ $ this ->eventDispatcher ->dispatchTyped (new BeforeJobExecutedEvent ($ job ));
128133 /** @psalm-suppress DeprecatedMethod Calling execute until it is removed, then will switch to start */
129134 $ job ->execute ($ this ->jobList );
135+ $ this ->eventDispatcher ->dispatchTyped (new JobExecutedEvent ($ job ));
130136
131137 $ output ->writeln ('Job ' . $ job ->getId () . ' has finished ' , OutputInterface::VERBOSITY_VERBOSE );
132138
0 commit comments