ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
RunActiveJobsCommand.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use Symfony\Component\Console\Input\InputInterface;
25use Symfony\Component\Console\Output\OutputInterface;
26use Symfony\Component\Console\Input\InputArgument;
27use Symfony\Component\Console\Style\StyleInterface;
28use Symfony\Component\Console\Style\SymfonyStyle;
30
32{
33 protected static $defaultName = 'run-jobs';
34
36 private $style;
37
38 protected function configure(): void
39 {
40 $this->setDescription('Runs cron jobs depending on the respective schedule');
41
42 $this->addArgument('user', InputArgument::REQUIRED, 'The ILIAS user the script is executed with');
43 $this->addArgument('client_id', InputArgument::REQUIRED, 'The ILIAS client_id');
44 }
45
46 protected function execute(InputInterface $input, OutputInterface $output): int
47 {
48 $this->style = new SymfonyStyle($input, $output);
49
50 $cron = new \ILIAS\Cron\CLI\StartUp(
51 $input->getArgument('client_id'),
52 $input->getArgument('user')
53 );
54
55 try {
56 $cron->authenticate();
57
58 $this->withAuthenticated($input, $output);
59
60 $this->style->success('Success');
61
62 return 0;
63 } catch (\Throwable $e) {
64 $this->style->error($e->getMessage());
65 $this->style->error($e->getTraceAsString());
66
67 return 1;
68 } finally {
69 $cron->logout();
70 }
71 }
72
73 private function withAuthenticated(InputInterface $input, OutputInterface $output): void
74 {
75 global $DIC;
76
77 $strict_job_manager = new StrictCliJobManager(
78 $DIC->cron()->manager()
79 );
80 $strict_job_manager->runActiveJobs($DIC->user());
81 }
82}
withAuthenticated(InputInterface $input, OutputInterface $output)
execute(InputInterface $input, OutputInterface $output)
$cron
Definition: cron.php:26
global $DIC
Definition: shib_login.php:26