15
15
use Statikbe \FilamentFlexibleContentBlockPages \Services \Enum \SitemapGeneratorMethod ;
16
16
use Statikbe \FilamentFlexibleContentBlocks \FilamentFlexibleBlocksConfig ;
17
17
use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasCode ;
18
- use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasPageAttributes ;
19
18
use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \HasParent ;
20
19
use Statikbe \FilamentFlexibleContentBlocks \Models \Contracts \Linkable ;
21
20
22
21
class SitemapGeneratorService
23
22
{
24
23
protected Sitemap $ sitemap ;
24
+
25
25
protected string $ canonicalLocale ;
26
+
26
27
protected array $ supportedLocales ;
27
28
28
29
public function __construct ()
@@ -35,15 +36,14 @@ public function __construct()
35
36
36
37
public function generate (): void
37
38
{
38
- if (!FilamentFlexibleContentBlockPages::config ()->isSitemapEnabled ()) {
39
+ if (! FilamentFlexibleContentBlockPages::config ()->isSitemapEnabled ()) {
39
40
return ;
40
41
}
41
42
42
43
$ method = FilamentFlexibleContentBlockPages::config ()->getSitemapMethod ();
43
44
if ($ method === SitemapGeneratorMethod::CRAWL ) {
44
45
$ this ->generateByCrawling ();
45
- }
46
- else if ($ method === SitemapGeneratorMethod::HYBRID ) {
46
+ } elseif ($ method === SitemapGeneratorMethod::HYBRID ) {
47
47
$ this ->generateByCrawling ();
48
48
$ this ->generateManually ();
49
49
} else {
@@ -143,7 +143,7 @@ protected function addLinkableModels(): void
143
143
144
144
$ modelQuery = $ modelClass ::query ();
145
145
146
- if (method_exists ($ modelClass , 'scopePublished ' )) {
146
+ if (method_exists ($ modelClass , 'scopePublished ' )) {
147
147
$ modelQuery ->published ();
148
148
}
149
149
@@ -233,17 +233,17 @@ protected function shouldExcludeUrl(string $url, array $excludePatterns): bool
233
233
return false ;
234
234
}
235
235
236
- protected function addToSitemap (string $ url , ?Carbon $ lastModifiedAt , float $ priority , string $ frequency , bool $ onlyCreate= false ): Url
236
+ protected function addToSitemap (string $ url , ?Carbon $ lastModifiedAt , float $ priority , string $ frequency , bool $ onlyCreate = false ): Url
237
237
{
238
238
$ urlTag = Url::create ($ url )
239
239
->setPriority ($ priority )
240
240
->setChangeFrequency ($ frequency );
241
241
242
- if ($ lastModifiedAt ) {
242
+ if ($ lastModifiedAt ) {
243
243
$ urlTag ->setLastModificationDate ($ lastModifiedAt );
244
244
}
245
245
246
- if (!$ onlyCreate ) {
246
+ if (! $ onlyCreate ) {
247
247
$ this ->sitemap ->add ($ urlTag );
248
248
}
249
249
0 commit comments