Skip to content

Commit

Permalink
Working on scheduled commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 19, 2014
1 parent 8161491 commit fb335c2
Show file tree
Hide file tree
Showing 15 changed files with 1,047 additions and 29 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -20,6 +20,7 @@
"jeremeamia/superclosure": "~1.0.1",
"league/flysystem": "0.6.*",
"monolog/monolog": "~1.6",
"mtdowling/cron-expression": "~1.0",
"nesbot/carbon": "~1.0",
"patchwork/utf8": "~1.1",
"predis/predis": "~1.0",
Expand Down
37 changes: 37 additions & 0 deletions src/Illuminate/Console/ScheduleServiceProvider.php
@@ -0,0 +1,37 @@
<?php namespace Illuminate\Console;

use Illuminate\Support\ServiceProvider;
use Illuminate\Console\Scheduling\ScheduleRunCommand;

class ScheduleServiceProvider extends ServiceProvider {

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = true;

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->commands('Illuminate\Console\Scheduling\ScheduleRunCommand');
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
'Illuminate\Console\Scheduling\ScheduleRunCommand',
];
}

}
64 changes: 64 additions & 0 deletions src/Illuminate/Console/Scheduling/CallbackEvent.php
@@ -0,0 +1,64 @@
<?php namespace Illuminate\Console\Scheduling;

use Illuminate\Contracts\Container\Container;

class CallbackEvent extends Event {

/**
* The callback to call.
*
* @var string
*/
protected $callback;

/**
* The parameters to pass to the method.
*
* @var array
*/
protected $parameters;

/**
* Create a new event instance.
*
* @param string $callback
* @param array $parameters
* @return void
*/
public function __construct($callback, array $parameters = array())
{
$this->callback = $callback;
$this->parameters = $parameters;

if ( ! is_string($this->callback) && ! is_callable($this->callback))
{
throw new \InvalidArgumentException(
"Invalid scheduled callback event. Must be string or callable."
);
}
}

/**
* Run the given event.
*
* @param \Illuminate\Contracts\Container\Container $app
* @return void
*/
public function run(Container $container)
{
return $container->call($this->callback, $this->parameters);
}

/**
* Get the summary of the event for display.
*
* @return string
*/
public function getSummaryForDisplay()
{
if (is_string($this->description)) return $this->description;

return is_string($this->callback) ? $this->callback : 'Closure';
}

}

3 comments on commit fb335c2

@aligajani
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taylor, this Scheduling feature looks great. Aren't you using Dispatcher by Indatus?

@Anahkiasen
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aligajani
Copy link

@aligajani aligajani commented on fb335c2 Nov 21, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.