@@ -25,12 +25,12 @@ |
||
25 | 25 | use OC\BackgroundJob\QueuedJob; |
26 | 26 | |
27 | 27 | class ClosureJob extends QueuedJob { |
28 | - protected function run($serializedCallable) { |
|
29 | - $callable = \Opis\Closure\unserialize($serializedCallable); |
|
30 | - if (is_callable($callable)) { |
|
31 | - $callable(); |
|
32 | - } else { |
|
33 | - throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | - } |
|
35 | - } |
|
28 | + protected function run($serializedCallable) { |
|
29 | + $callable = \Opis\Closure\unserialize($serializedCallable); |
|
30 | + if (is_callable($callable)) { |
|
31 | + $callable(); |
|
32 | + } else { |
|
33 | + throw new \InvalidArgumentException('Invalid serialized callable'); |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | * Wrap a command in the background job interface |
30 | 30 | */ |
31 | 31 | class CommandJob extends QueuedJob { |
32 | - protected function run($serializedCommand) { |
|
33 | - $command = \Opis\Closure\unserialize($serializedCommand); |
|
34 | - if ($command instanceof ICommand) { |
|
35 | - $command->handle(); |
|
36 | - } else { |
|
37 | - throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | - } |
|
39 | - } |
|
32 | + protected function run($serializedCommand) { |
|
33 | + $command = \Opis\Closure\unserialize($serializedCommand); |
|
34 | + if ($command instanceof ICommand) { |
|
35 | + $command->handle(); |
|
36 | + } else { |
|
37 | + throw new \InvalidArgumentException('Invalid serialized command'); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | } |
@@ -28,50 +28,50 @@ |
||
28 | 28 | use OCP\Command\ICommand; |
29 | 29 | |
30 | 30 | class CronBus extends AsyncBus { |
31 | - /** |
|
32 | - * @var \OCP\BackgroundJob\IJobList |
|
33 | - */ |
|
34 | - private $jobList; |
|
31 | + /** |
|
32 | + * @var \OCP\BackgroundJob\IJobList |
|
33 | + */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @param \OCP\BackgroundJob\IJobList $jobList |
|
39 | - */ |
|
40 | - public function __construct($jobList) { |
|
41 | - $this->jobList = $jobList; |
|
42 | - } |
|
37 | + /** |
|
38 | + * @param \OCP\BackgroundJob\IJobList $jobList |
|
39 | + */ |
|
40 | + public function __construct($jobList) { |
|
41 | + $this->jobList = $jobList; |
|
42 | + } |
|
43 | 43 | |
44 | - protected function queueCommand($command) { |
|
45 | - $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command)); |
|
46 | - } |
|
44 | + protected function queueCommand($command) { |
|
45 | + $this->jobList->add($this->getJobClass($command), $this->serializeCommand($command)); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param \OCP\Command\ICommand | callable $command |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - private function getJobClass($command) { |
|
53 | - if ($command instanceof \Closure) { |
|
54 | - return ClosureJob::class; |
|
55 | - } elseif (is_callable($command)) { |
|
56 | - return CallableJob::class; |
|
57 | - } elseif ($command instanceof ICommand) { |
|
58 | - return CommandJob::class; |
|
59 | - } else { |
|
60 | - throw new \InvalidArgumentException('Invalid command'); |
|
61 | - } |
|
62 | - } |
|
48 | + /** |
|
49 | + * @param \OCP\Command\ICommand | callable $command |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + private function getJobClass($command) { |
|
53 | + if ($command instanceof \Closure) { |
|
54 | + return ClosureJob::class; |
|
55 | + } elseif (is_callable($command)) { |
|
56 | + return CallableJob::class; |
|
57 | + } elseif ($command instanceof ICommand) { |
|
58 | + return CommandJob::class; |
|
59 | + } else { |
|
60 | + throw new \InvalidArgumentException('Invalid command'); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param \OCP\Command\ICommand | callable $command |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - private function serializeCommand($command) { |
|
69 | - if ($command instanceof \Closure) { |
|
70 | - return \Opis\Closure\serialize($command); |
|
71 | - } elseif (is_callable($command) or $command instanceof ICommand) { |
|
72 | - return \Opis\Closure\serialize($command); |
|
73 | - } else { |
|
74 | - throw new \InvalidArgumentException('Invalid command'); |
|
75 | - } |
|
76 | - } |
|
64 | + /** |
|
65 | + * @param \OCP\Command\ICommand | callable $command |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + private function serializeCommand($command) { |
|
69 | + if ($command instanceof \Closure) { |
|
70 | + return \Opis\Closure\serialize($command); |
|
71 | + } elseif (is_callable($command) or $command instanceof ICommand) { |
|
72 | + return \Opis\Closure\serialize($command); |
|
73 | + } else { |
|
74 | + throw new \InvalidArgumentException('Invalid command'); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |