Skip to content

Commit fb335c2

Browse files
committed
Working on scheduled commands.
1 parent 8161491 commit fb335c2

File tree

15 files changed

+1047
-29
lines changed

15 files changed

+1047
-29
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"jeremeamia/superclosure": "~1.0.1",
2121
"league/flysystem": "0.6.*",
2222
"monolog/monolog": "~1.6",
23+
"mtdowling/cron-expression": "~1.0",
2324
"nesbot/carbon": "~1.0",
2425
"patchwork/utf8": "~1.1",
2526
"predis/predis": "~1.0",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php namespace Illuminate\Console;
2+
3+
use Illuminate\Support\ServiceProvider;
4+
use Illuminate\Console\Scheduling\ScheduleRunCommand;
5+
6+
class ScheduleServiceProvider extends ServiceProvider {
7+
8+
/**
9+
* Indicates if loading of the provider is deferred.
10+
*
11+
* @var bool
12+
*/
13+
protected $defer = true;
14+
15+
/**
16+
* Register the service provider.
17+
*
18+
* @return void
19+
*/
20+
public function register()
21+
{
22+
$this->commands('Illuminate\Console\Scheduling\ScheduleRunCommand');
23+
}
24+
25+
/**
26+
* Get the services provided by the provider.
27+
*
28+
* @return array
29+
*/
30+
public function provides()
31+
{
32+
return [
33+
'Illuminate\Console\Scheduling\ScheduleRunCommand',
34+
];
35+
}
36+
37+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php namespace Illuminate\Console\Scheduling;
2+
3+
use Illuminate\Contracts\Container\Container;
4+
5+
class CallbackEvent extends Event {
6+
7+
/**
8+
* The callback to call.
9+
*
10+
* @var string
11+
*/
12+
protected $callback;
13+
14+
/**
15+
* The parameters to pass to the method.
16+
*
17+
* @var array
18+
*/
19+
protected $parameters;
20+
21+
/**
22+
* Create a new event instance.
23+
*
24+
* @param string $callback
25+
* @param array $parameters
26+
* @return void
27+
*/
28+
public function __construct($callback, array $parameters = array())
29+
{
30+
$this->callback = $callback;
31+
$this->parameters = $parameters;
32+
33+
if ( ! is_string($this->callback) && ! is_callable($this->callback))
34+
{
35+
throw new \InvalidArgumentException(
36+
"Invalid scheduled callback event. Must be string or callable."
37+
);
38+
}
39+
}
40+
41+
/**
42+
* Run the given event.
43+
*
44+
* @param \Illuminate\Contracts\Container\Container $app
45+
* @return void
46+
*/
47+
public function run(Container $container)
48+
{
49+
return $container->call($this->callback, $this->parameters);
50+
}
51+
52+
/**
53+
* Get the summary of the event for display.
54+
*
55+
* @return string
56+
*/
57+
public function getSummaryForDisplay()
58+
{
59+
if (is_string($this->description)) return $this->description;
60+
61+
return is_string($this->callback) ? $this->callback : 'Closure';
62+
}
63+
64+
}

0 commit comments

Comments
 (0)