CronServiceProvider.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\common\providers;
  3. use app\console\Commands\CronRun;
  4. use app\framework\Cron\Cron;
  5. use Liebig\Cron\KeygenCommand;
  6. use Liebig\Cron\Laravel5ServiceProvider;
  7. use Liebig\Cron\ListCommand;
  8. class CronServiceProvider extends Laravel5ServiceProvider
  9. {
  10. /**
  11. * Register the application services.
  12. *
  13. * @return void
  14. */
  15. public function register() {
  16. $this->app->singleton('cron', function () {
  17. return new Cron();
  18. });
  19. $this->app->booting(function() {
  20. $loader = \Illuminate\Foundation\AliasLoader::getInstance();
  21. $loader->alias('Cron', 'Liebig\Cron\Facades\Cron');
  22. });
  23. $this->app->singleton('cron::command.run', function () {
  24. return new CronRun();
  25. });
  26. $this->commands('cron::command.run');
  27. $this->app->singleton('cron::command.list', function () {
  28. return new ListCommand;
  29. });
  30. $this->commands('cron::command.list');
  31. $this->app->singleton('cron::command.keygen', function () {
  32. return new KeygenCommand;
  33. });
  34. $this->commands('cron::command.keygen');
  35. }
  36. }