Total Complexity | 3 |
Total Lines | 48 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class GenerateSitemap extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $signature = 'sitemap:generate'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Generate the sitemap.'; |
||
24 | |||
25 | /** |
||
26 | * Set the signature. |
||
27 | * |
||
28 | * @param string $signature |
||
29 | */ |
||
30 | public function __construct(string $signature = 'sitemap:generate') |
||
31 | { |
||
32 | $this->signature = $signature; |
||
33 | |||
34 | parent::__construct(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Execute the console command. |
||
39 | * |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function handle(SitemapGenerator $sitemapGenerator) |
||
43 | { |
||
44 | $sitemapGenerator |
||
45 | ->setUrl(config('app.url')) |
||
46 | ->writeToFile(public_path('sitemap.xml')); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Register the command. |
||
51 | * |
||
52 | * @return void |
||
53 | */ |
||
54 | public static function register(string $signature = 'sitemap:generate') |
||
57 | } |
||
58 | } |
||
59 |