2021-08-31 22:28:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Kwaadpepper\RefreshSitemap;
|
|
|
|
|
|
2021-09-04 00:39:12 +02:00
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
2021-08-31 22:28:29 +02:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2022-06-10 17:38:34 +02:00
|
|
|
use Kwaadpepper\RefreshSitemap\Console\Commands\RefreshSitemap;
|
2021-09-04 00:39:12 +02:00
|
|
|
use Kwaadpepper\RefreshSitemap\Jobs\GenerateSitemap;
|
2021-08-31 22:28:29 +02:00
|
|
|
|
|
|
|
|
class RefreshSitemapServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Bootstrap any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2022-06-10 17:38:34 +02:00
|
|
|
public function boot(): void
|
2021-08-31 22:28:29 +02:00
|
|
|
{
|
|
|
|
|
$this->publishes([
|
2021-09-04 00:39:12 +02:00
|
|
|
__DIR__ . '/../config' => \config_path(),
|
2021-08-31 22:28:29 +02:00
|
|
|
], 'config');
|
2021-09-04 00:39:12 +02:00
|
|
|
|
|
|
|
|
if (\config('refresh-sitemap.schedule', false)) {
|
|
|
|
|
$this->app->booted(function () {
|
|
|
|
|
/** @var \Illuminate\Console\Scheduling\Schedule $schedule */
|
|
|
|
|
$schedule = app(Schedule::class);
|
|
|
|
|
$schedule->job(GenerateSitemap::class)
|
|
|
|
|
->cron(\config('refresh-sitemap.cron', '45 15 * * *'));
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-08-31 22:28:29 +02:00
|
|
|
}
|
|
|
|
|
|
2022-06-10 17:38:34 +02:00
|
|
|
/**
|
|
|
|
|
* Register any application services.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function register(): void
|
2021-08-31 22:28:29 +02:00
|
|
|
{
|
|
|
|
|
$this->mergeConfigFrom(
|
2021-09-04 00:39:12 +02:00
|
|
|
\sprintf('%s/../config/refresh-sitemap.php', __DIR__),
|
2021-08-31 22:28:29 +02:00
|
|
|
'refresh-sitemap'
|
|
|
|
|
);
|
2022-06-10 17:38:34 +02:00
|
|
|
$this->commands([
|
|
|
|
|
RefreshSitemap::class
|
|
|
|
|
]);
|
2021-08-31 22:28:29 +02:00
|
|
|
}
|
|
|
|
|
}
|