class SitemapWriter (View source)

Constants

EVENTNAME_ELEMENTREADY

Name of the event called when a page is going to be added to the sitemap.

EVENTNAME_PAGEREADY_DEPRECATED

Name of the deprecated event called when a page is going to be added to the sitemap.

EVENTNAME_XMLREADY

Name of the event called when the whole XML is ready.

MODE_AUTO

Write mode: automatic (MODE_HIGHMEMORY if the on_sitemap_xml_addingpage/on_sitemap_xml_ready events are hooked, MODE_LOWMEMORY otherwise).

MODE_LOWMEMORY

Write mode: use less memory (the on_sitemap_xml_addingpage/on_sitemap_xml_ready events won't be fired).

MODE_HIGHMEMORY

Write mode: use more memory (the on_sitemap_xml_addingpage/on_sitemap_xml_ready event will be called).

Properties

protected Application $app
protected Filesystem $filesystem
protected int $mode The write mode.
protected EventDispatcherInterface $director
protected string $indenter
protected string $lineTerminator
private SitemapGenerator|null $sitemapGenerator
private string $outputFilename
private string $temporaryDirectory

Methods

__construct(Application $app, Filesystem $filesystem, EventDispatcherInterface $director)

No description

int
getMode()

Get the write mode.

$this
setMode(int $mode)

Set the write mode.

string
getIndenter()

Get the string used to indent the XML when the mode is set to MODE_LOWMEMORY.

$this
setIndenter(string $indenter)

Set the string used to indent the XML when the mode is set to MODE_LOWMEMORY.

string
getLineTerminator()

Get the string used as new-line terminator in the XML when the mode is set to MODE_LOWMEMORY.

$this
setLineTerminator(string $lineTerminator)

Get the string used as new-line terminator in the XML when the mode is set to MODE_LOWMEMORY.

getSitemapGenerator()

Get the SitemapGenerator instance to be used.

$this
setSitemapGenerator(SitemapGenerator $sitemapGenerator)

Set the SitemapGenerator instance to be used.

$this
setOutputFilename(string $outputFilename)

Set the path to the sitemap to be generated.

string
getOutputFilename()

Get the path to the sitemap to be generated.

string
getSitemapUrl()

Get the URL of the sitemap corresponding to the output file name.

generate(callable $pulse = null)

Generate the sitemap.

string
getTemporaryDirectory()

Get the temporary directory to be used during the sitemap generation.

checkOutputFilename(string $outputFilename)

No description

Details

__construct(Application $app, Filesystem $filesystem, EventDispatcherInterface $director)

Parameters

Application $app
Filesystem $filesystem
EventDispatcherInterface $director

int getMode()

Get the write mode.

Return Value

int One of the SitemapWriter::MODE_... constants.

$this setMode(int $mode)

Set the write mode.

Parameters

int $mode One of the SitemapWriter::MODE_... constants.

Return Value

$this

string getIndenter()

Get the string used to indent the XML when the mode is set to MODE_LOWMEMORY.

Return Value

string

$this setIndenter(string $indenter)

Set the string used to indent the XML when the mode is set to MODE_LOWMEMORY.

Parameters

string $indenter

Return Value

$this

string getLineTerminator()

Get the string used as new-line terminator in the XML when the mode is set to MODE_LOWMEMORY.

Return Value

string

$this setLineTerminator(string $lineTerminator)

Get the string used as new-line terminator in the XML when the mode is set to MODE_LOWMEMORY.

Parameters

string $lineTerminator

Return Value

$this

SitemapGenerator getSitemapGenerator()

Get the SitemapGenerator instance to be used.

Return Value

SitemapGenerator

$this setSitemapGenerator(SitemapGenerator $sitemapGenerator)

Set the SitemapGenerator instance to be used.

Parameters

SitemapGenerator $sitemapGenerator

Return Value

$this

$this setOutputFilename(string $outputFilename)

Set the path to the sitemap to be generated.

Parameters

string $outputFilename

Return Value

$this

string getOutputFilename()

Get the path to the sitemap to be generated.

Return Value

string

string getSitemapUrl()

Get the URL of the sitemap corresponding to the output file name.

Return Value

string returns an empty string if the output file name is not under the web root

generate(callable $pulse = null)

Generate the sitemap.

Parameters

callable $pulse a callback function to be called every time a new sitemap element will be processed

protected string getTemporaryDirectory()

Get the temporary directory to be used during the sitemap generation.

Return Value

string

protected checkOutputFilename(string $outputFilename)

Parameters

string $outputFilename

Exceptions

UserMessageException