Test Setup Failed
Push — master ( 01ce13...70ac53 )
by
unknown
07:04
created

GenerateImageSitemap   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 13 2
1
<?php
2
3
namespace Thinktomorrow\Chief\App\Console;
4
5
use Thinktomorrow\Chief\Site\Sitemap\ImageSitemapXmlFile;
6
7
class GenerateImageSitemap extends BaseCommand
8
{
9
    protected $signature = 'chief:image-sitemap';
10
    protected $description = 'Generate an image sitemap for all locales. Only online and visitable image urls are included.';
11
    /**
12
     * @var ImageSitemapXmlFile
13
     */
14
    private $sitemapXmlFile;
15
16
    public function __construct(ImageSitemapXmlFile $sitemapXmlFile)
17
    {
18
        parent::__construct();
19
20
        $this->sitemapXmlFile = $sitemapXmlFile;
21
    }
22
23
    public function handle(): void
24
    {
25
        $locales = config('chief.locales');
26
27
        foreach ($locales as $locale) {
28
            $filepath = public_path('image-sitemap-' . $locale . '.xml');
29
30
            $this->info('Generating an image sitemap for locale: ' . $locale . ' at: ' . $filepath);
31
32
            $this->sitemapXmlFile->create($locale, $filepath);
33
        }
34
35
        $this->info('Done generating sitemaps.');
36
    }
37
}
38