Current state with latest updates
This commit is contained in:
@@ -42,6 +42,23 @@ final class SitemapBuildService
|
||||
*/
|
||||
public function buildNamed(string $name, bool $force = false, bool $persist = true): ?array
|
||||
{
|
||||
$groupFamilies = $this->groupFamilies($name);
|
||||
if ($groupFamilies !== null) {
|
||||
$built = $this->cache->remember(
|
||||
$name,
|
||||
fn (): string => $this->renderer->renderIndex($this->index->itemsForFamilies($groupFamilies)),
|
||||
$force,
|
||||
$persist,
|
||||
);
|
||||
|
||||
return $built + [
|
||||
'type' => SitemapTarget::TYPE_INDEX,
|
||||
'url_count' => count($this->index->itemsForFamilies($groupFamilies)),
|
||||
'shard_count' => 0,
|
||||
'name' => $name,
|
||||
];
|
||||
}
|
||||
|
||||
$target = $this->shards->resolve($this->registry, $name);
|
||||
|
||||
if ($target === null) {
|
||||
@@ -111,6 +128,24 @@ final class SitemapBuildService
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>|null
|
||||
*/
|
||||
public function groupFamilies(string $name): ?array
|
||||
{
|
||||
$families = $this->index->activeGroupIndexes($this->enabledFamilies())[$name] ?? null;
|
||||
|
||||
return is_array($families) && $families !== [] ? $families : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function enabledGroupIndexes(): array
|
||||
{
|
||||
return $this->index->activeGroupIndexes($this->enabledFamilies());
|
||||
}
|
||||
|
||||
private function renderTarget(SitemapTarget $target): string
|
||||
{
|
||||
if ($target->type === SitemapTarget::TYPE_INDEX) {
|
||||
@@ -140,4 +175,4 @@ final class SitemapBuildService
|
||||
|
||||
return count($target->builder->items());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user