SitemapUrlsetWriter
in package
Writes one sitemap `<urlset>` file with hreflang alternatives, streaming.
Each entry is flushed to the file right after it is written, so memory holds only the entry in
progress. The output is formatted with a two-space indent and an empty document is <urlset/>.
The byte count reflects what was actually written; SitemapBucketWriter uses it to guard the protocol limit of 50 MB.
Table of Contents
Constants
- NS_SITEMAP : mixed = 'http://www.sitemaps.org/schemas/sitemap/0.9'
- NS_XHTML : mixed = 'http://www.w3.org/1999/xhtml'
Properties
- $buffer : string
- $byteCount : int
- $closed : bool
- $handle : resource|null
- $urlCount : int
- $xml : XMLWriter
Methods
- addEntry() : void
- Writes one entry: a `<url>` per language version, each linking to all versions.
- close() : string
- Closes the document; returns the whole XML for in-memory output and an empty string for a file.
- discard() : void
- Closes the file without finishing the document (after an error; the caller removes the temporary file).
- getByteCount() : int
- Returns the bytes already written (for a file, actually sent to the file).
- getUrlCount() : int
- toFile() : self
- toMemory() : self
- __construct() : mixed
- drain() : void
Constants
NS_SITEMAP
public
mixed
NS_SITEMAP
= 'http://www.sitemaps.org/schemas/sitemap/0.9'
NS_XHTML
public
mixed
NS_XHTML
= 'http://www.w3.org/1999/xhtml'
Properties
$buffer
private
string
$buffer
= ''
$byteCount
private
int
$byteCount
= 0
$closed
private
bool
$closed
= false
$handle
private
resource|null
$handle
target file; null means in-memory output (returned by close())
$urlCount
private
int
$urlCount
= 0
$xml
private
XMLWriter
$xml
Methods
addEntry()
Writes one entry: a `<url>` per language version, each linking to all versions.
public
addEntry(array<string, string> $urlsByLocale, array{changefreq?: ?string, priority?: ?string, lastmod?: ?string} $meta) : void
Parameters
- $urlsByLocale : array<string, string>
-
locale key => absolute URL
- $meta : array{changefreq?: ?string, priority?: ?string, lastmod?: ?string}
close()
Closes the document; returns the whole XML for in-memory output and an empty string for a file.
public
close() : string
Tags
Return values
stringdiscard()
Closes the file without finishing the document (after an error; the caller removes the temporary file).
public
discard() : void
getByteCount()
Returns the bytes already written (for a file, actually sent to the file).
public
getByteCount() : int
Return values
intgetUrlCount()
public
getUrlCount() : int
Return values
inttoFile()
public
static toFile(string $path) : self
Parameters
- $path : string
Tags
Return values
selftoMemory()
public
static toMemory() : self
Return values
self__construct()
private
__construct(resource|null $handle) : mixed
Parameters
- $handle : resource|null
drain()
private
drain() : void