You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Command/RunCommand.php
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
8
8
namespaceRewieer\TaskSchedulerBundle\Command;
9
9
10
+
useException;
10
11
useRewieer\TaskSchedulerBundle\Task\Scheduler;
11
12
useSymfony\Component\Console\Command\Command;
12
13
useSymfony\Component\Console\Input\InputArgument;
@@ -16,10 +17,7 @@
16
17
17
18
class RunCommand extends Command
18
19
{
19
-
/**
20
-
* @var Scheduler
21
-
*/
22
-
private$scheduler;
20
+
privateScheduler$scheduler;
23
21
24
22
publicfunction__construct(Scheduler$scheduler)
25
23
{
@@ -32,7 +30,11 @@ protected function configure(): void
32
30
$this
33
31
->setName("ts:run")
34
32
->setDescription("Run due tasks")
35
-
->setHelp("This command actually run the tasks that are due at the moment the command is called.\nThis command should not be called manually. Check the documentation to learn how to set CRON jobs.")
33
+
->setHelp(<<<'EOF'
34
+
This command actually run the tasks that are due at the moment the command is called.
35
+
This command should not be called manually. Check the documentation to learn how to set CRON jobs.
36
+
EOF
37
+
)
36
38
->addArgument("id", InputArgument::OPTIONAL, "The ID of the task. Check ts:list for IDs")
37
39
->addOption("class", "c", InputOption::VALUE_OPTIONAL, "the class name of the task (without namespace)");
38
40
}
@@ -42,29 +44,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int
42
44
$id = $input->getArgument("id");
43
45
$class = $input->getOption("class");
44
46
45
-
46
47
if (!$id && !$class) {
47
48
$this->scheduler->run();
48
49
} elseif ($class) {
49
50
$tasks = $this->scheduler->getTasks();
50
51
foreach ($tasksas$task) {
51
52
if (strpos(get_class($task), "\\$class")) {
52
53
$this->scheduler->runTask($task);
53
-
return0;
54
+
returnself::SUCCESS;
54
55
}
55
56
}
56
-
thrownew\Exception("There are no tasks corresponding to this class name");
57
+
thrownewException("There are no tasks corresponding to this class name");
57
58
} else {
58
59
$tasks = $this->scheduler->getTasks();
59
60
$id = (int)$id;
60
61
61
62
if (array_key_exists($id - 1, $tasks) === false) {
62
-
thrownew\Exception("There are no tasks corresponding to this ID");
63
+
thrownewException("There are no tasks corresponding to this ID");
0 commit comments