final class SitemapGenerator (View source)

Normalizes sitemap URLs and serializes them either to a target stream or as lazy XML chunks

Methods

__construct(SitemapProviderRegistry $registry, BaseUrlResolver $baseUrlResolver, SitemapConfig $config, LoggerInterface|null $logger = null)

Initializes sitemap generation with provider discovery and URL normalization dependencies

iterable
urls()

Lazily resolves valid sitemap URLs from registered providers

iterable
iterable
urlsetChunks(iterable $urls)

Lazily yields XML urlset chunks without assembling the full sitemap in memory

iterable
array
writeUrlset(resource $stream, iterable $urls)

Writes a complete XML urlset to the supplied resource stream

array
void

Writes the beginning of an XML urlset through the XML writer

void
void

Writes the end of an XML urlset through the XML writer

void
void

Writes one URL element with all available sitemap attributes

void

Details

__construct

__construct(SitemapProviderRegistry $registry, BaseUrlResolver $baseUrlResolver, SitemapConfig $config, LoggerInterface|null $logger = null)

Initializes sitemap generation with provider discovery and URL normalization dependencies

Parameters

SitemapProviderRegistry $registry
BaseUrlResolver $baseUrlResolver
SitemapConfig $config
LoggerInterface|null $logger

urls

iterable urls()

Lazily resolves valid sitemap URLs from registered providers

Return Value

iterable

urlsetChunks

iterable urlsetChunks(iterable $urls)

Lazily yields XML urlset chunks without assembling the full sitemap in memory

Parameters

iterable $urls

Return Value

iterable

writeUrlset

array writeUrlset(resource $stream, iterable $urls)

Writes a complete XML urlset to the supplied resource stream

Parameters

resource $stream
iterable $urls

Return Value

array

startUrlset

void startUrlset(XmlStreamWriter $xml)

Writes the beginning of an XML urlset through the XML writer

Parameters

XmlStreamWriter $xml

Return Value

void

endUrlset

void endUrlset(XmlStreamWriter $xml)

Writes the end of an XML urlset through the XML writer

Parameters

XmlStreamWriter $xml

Return Value

void

writeUrlElement

void writeUrlElement(XmlStreamWriter $xml, SitemapUrl $url)

Writes one URL element with all available sitemap attributes

Parameters

XmlStreamWriter $xml
SitemapUrl $url

Return Value

void