@@ -20,27 +20,19 @@ class JobManager
20
20
/**
21
21
* @var ScheduledJobService
22
22
*/
23
- private $ scheduledJob ;
23
+ private $ scheduledJobService ;
24
24
25
25
public function __construct (
26
26
JobPublisher $ publisher ,
27
27
ScheduledJobService $ scheduledJobService
28
28
) {
29
29
$ this ->publisher = $ publisher ;
30
- $ this ->scheduledJob = $ scheduledJobService ;
30
+ $ this ->scheduledJobService = $ scheduledJobService ;
31
31
}
32
32
33
- /**
34
- * Adds a job to the resque queue
35
- * @param Job $job
36
- */
37
- public function addJob (Job $ job , $ dateTime = null )
33
+ public function addJob (Job $ job , $ supressLogging = false )
38
34
{
39
- if ($ dateTime === null ) {
40
- $ this ->publisher ->publish ($ job );
41
- } elseif ($ job instanceof ConsoleCommandJob) {
42
- $ this ->scheduledJob ->addScheduledJob ($ job , $ dateTime );
43
- }
35
+ $ this ->publisher ->publish ($ job , $ supressLogging );
44
36
}
45
37
46
38
/**
@@ -51,8 +43,9 @@ public function addJob(Job $job, $dateTime = null)
51
43
* @param string $topic The name of a valid topic.
52
44
* @param integer $timeout The amount of time to allow the command to run.
53
45
* @param integer $idleTimeout The amount of idle time to allow the command to run. Defaults to the same as timeout.
46
+ * @param bool $supressLogging Stops the job from being logged by the database
54
47
*/
55
- public function addConsoleCommandJob (string $ command , array $ arguments = [], $ topic = 'default ' , $ timeout = 60 , $ idleTimeout = null )
48
+ public function addConsoleCommandJob (string $ command , array $ arguments = [], $ topic = 'default ' , $ timeout = 60 , $ idleTimeout = null , $ supressLogging = false )
56
49
{
57
50
if (stripos ($ command , " " ) !== false ) {
58
51
throw new \InvalidArgumentException ('Console command is not expected to have spaces within the name ' );
@@ -64,7 +57,8 @@ public function addConsoleCommandJob(string $command, array $arguments = [], $to
64
57
$ args ['timeout ' ] = $ timeout ;
65
58
$ args ['idleTimeout ' ] = $ idleTimeout ?? $ timeout ;
66
59
$ job = new ConsoleCommandJob ($ args , $ topic );
67
- $ this ->addJob ($ job );
60
+
61
+ $ this ->addJob ($ job , $ supressLogging );
68
62
}
69
63
70
64
/**
@@ -95,6 +89,7 @@ public function addScheduledConsoleCommandJob(
95
89
$ args ['timeout ' ] = $ timeout ;
96
90
$ args ['idleTimeout ' ] = $ idleTimeout ?? $ timeout ;
97
91
$ job = new ConsoleCommandJob ($ args , $ topic );
98
- $ this ->addJob ($ job , $ dateTime );
92
+
93
+ $ this ->scheduledJobService ->addScheduledJob ($ job , $ dateTime );
99
94
}
100
95
}
0 commit comments