|
1
|
|
|
<?php namespace Indatus\Dispatcher\Commands; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of Dispatcher |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Ben Kuhl <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
use App; |
|
13
|
|
|
use Illuminate\Console\Command; |
|
14
|
|
|
use Indatus\Dispatcher\Services\CommandService; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Run any commands that should be run |
|
19
|
|
|
* @author Ben Kuhl <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class Run extends Command |
|
22
|
|
|
{ |
|
23
|
|
|
/** @var \Indatus\Dispatcher\Services\CommandService|null */ |
|
24
|
|
|
private $commandService = null; |
|
25
|
|
|
|
|
26
|
3 |
|
public function __construct(CommandService $commandService) |
|
27
|
|
|
{ |
|
28
|
3 |
|
parent::__construct(); |
|
29
|
|
|
|
|
30
|
3 |
|
$this->commandService = $commandService; |
|
31
|
3 |
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The console command name. |
|
35
|
|
|
* |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $name = 'scheduled:run'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* The console command description. |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
protected $description = 'Run scheduled commands'; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Get the console command options. |
|
49
|
|
|
* |
|
50
|
|
|
* @return array |
|
51
|
|
|
*/ |
|
52
|
3 |
|
protected function getOptions() |
|
53
|
|
|
{ |
|
54
|
|
|
return [ |
|
55
|
3 |
|
['debug', 'd', InputOption::VALUE_NONE, 'Output debug information about why commands do/don\'t run.'], |
|
56
|
3 |
|
]; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Execute the console command. |
|
61
|
|
|
* |
|
62
|
|
|
* @return mixed |
|
63
|
|
|
*/ |
|
64
|
1 |
|
public function fire() |
|
65
|
|
|
{ |
|
66
|
|
|
/** @var \Indatus\Dispatcher\OptionReader $optionReader */ |
|
67
|
1 |
|
$optionReader = App::make('Indatus\Dispatcher\OptionReader', [ |
|
68
|
1 |
|
$this->option(), |
|
69
|
1 |
|
]); |
|
70
|
|
|
|
|
71
|
|
|
/** @var \Indatus\Dispatcher\Debugger $debugger */ |
|
72
|
1 |
|
$debugger = App::make('Indatus\Dispatcher\Debugger', [ |
|
73
|
1 |
|
$optionReader, |
|
74
|
1 |
|
$this->getOutput(), |
|
75
|
1 |
|
]); |
|
76
|
|
|
|
|
77
|
1 |
|
$this->commandService->runDue($debugger); |
|
78
|
1 |
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|