Skip to content

Commit

Permalink
Merge pull request #54 from balazsbencs-attrecto/master
Browse files Browse the repository at this point in the history
fix overwritten scheduled jobs
  • Loading branch information
Andreas Strömgren committed Oct 15, 2018
2 parents 87be7ff + 371c667 commit 58f4da3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/GdprServiceProvider.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Illuminate\Console\Scheduling\Schedule;
use Dialect\Gdpr\Commands\AnonymizeInactiveUsers;

class GdprServiceProvider extends ServiceProvider
Expand All @@ -25,6 +26,12 @@ public function boot()
__DIR__.'/middleware/RedirectIfUnansweredTerms.php' => base_path('app/Http/Middleware/RedirectIfUnansweredTerms.php'),
__DIR__.'/Http/Controllers/GdprController.php' => base_path('app/Http/Controllers/GdprController.php'),
], 'gdpr-consent');

// add scheduled job without overriding any other scheduled jobs
$this->app->booted(function () {
$schedule = $this->app->make(Schedule::class);
$schedule->command(AnonymizeInactiveUsers::class)->daily();
});
}

/**
Expand Down Expand Up @@ -61,7 +68,6 @@ public function register()
{
$this->configure();
$this->offerPublishing();
$this->addScheduledJobs();
}

/**
Expand All @@ -87,15 +93,4 @@ protected function offerPublishing()
], 'gdpr-config');
}
}

protected function addScheduledJobs()
{
$this->app->singleton('dialect.gdpr.console.kernel', function ($app) {
$dispatcher = $app->make(\Illuminate\Contracts\Events\Dispatcher::class);

return new \dialect\gdpr\console\Kernel($app, $dispatcher);
});

$this->app->make('dialect.gdpr.console.kernel');
}
}

0 comments on commit 58f4da3

Please sign in to comment.