Generator
in package
Class for generating sitemaps
Tags
Table of Contents
- $baseSitemapUrl : string
- Base URL for sitemap
- $baseUrl : mixed
- $config : Config
- $countPerPage : int
- URL entries per sitemap
- $fileLocation : string
- Output file path
- $fileStart : string
- Base path to sitemap files, including base filename
- $frequency : string
- Frequency of URL updates (always, daily, weekly, monthly, yearly, never)
- $indexFile : string
- Filename of sitemap index
- $languages : array<string|int, mixed>
- Languages enabled for sitemaps
- $pluginManager : PluginManager
- $verbose : callable
- Verbose callback
- $warnings : array<string|int, mixed>
- Warnings thrown during sitemap generation
- __construct() : mixed
- Constructor
- generate() : void
- Generate the sitemaps based on settings established by the constructor.
- getWarnings() : array<string|int, mixed>
- Get array of warning messages thrown during build.
- setBaseSitemapUrl() : string
- Get/set base sitemap url
- setBaseUrl() : string
- Get/set base url
- setFileLocation() : string
- Get/set output file path
- setVerbose() : callable|null
- Get/set verbose callback
- buildIndex() : void
- Write a sitemap index if requested.
- generateWithPlugins() : array<string|int, mixed>
- Generate sitemaps from all mandatory and configured plugins
- getBaseSitemapIndexUrl() : string
- Get the base URL for sitemap index files
- getFilenameForPage() : string
- Get the filename for the specified page number or name.
- getNewSitemap() : Sitemap
- Get a fresh Sitemap object.
- getNewSitemapIndex() : SitemapIndex
- Get a fresh SitemapIndex object.
- getPlugin() : GeneratorPluginInterface
- Create and setup a plugin
- getSitemapLanguages() : array<string|int, mixed>
- Get languages for a sitemap
- getTime() : float
- Get the current microtime, formatted to a number.
- verboseMsg() : void
- Write a verbose message (if configured to do so)
Properties
$baseSitemapUrl
Base URL for sitemap
protected
string
$baseSitemapUrl
$baseUrl
protected
mixed
$baseUrl
$config
protected
Config
$config
$countPerPage
URL entries per sitemap
protected
int
$countPerPage
$fileLocation
Output file path
protected
string
$fileLocation
$fileStart
Base path to sitemap files, including base filename
protected
string
$fileStart
$frequency
Frequency of URL updates (always, daily, weekly, monthly, yearly, never)
protected
string
$frequency
$indexFile
Filename of sitemap index
protected
string
$indexFile
= false
$languages
Languages enabled for sitemaps
protected
array<string|int, mixed>
$languages
$pluginManager
protected
PluginManager
$pluginManager
$verbose
Verbose callback
protected
callable
$verbose
= null
$warnings
Warnings thrown during sitemap generation
protected
array<string|int, mixed>
$warnings
= []
Methods
__construct()
Constructor
public
__construct(string $baseUrl, Config $config, array<string|int, mixed> $locales, PluginManager $pluginManager) : mixed
Parameters
- $baseUrl : string
-
VuFind base URL
- $config : Config
-
Sitemap configuration settings
- $locales : array<string|int, mixed>
-
Enabled locales
- $pluginManager : PluginManager
-
Generator plugin manager
Return values
mixed —generate()
Generate the sitemaps based on settings established by the constructor.
public
generate() : void
Return values
void —getWarnings()
Get array of warning messages thrown during build.
public
getWarnings() : array<string|int, mixed>
Return values
array<string|int, mixed> —setBaseSitemapUrl()
Get/set base sitemap url
public
setBaseSitemapUrl([string $newUrl = null ]) : string
Parameters
- $newUrl : string = null
-
New base sitemap url
Return values
string —Current or new base sitemap url
setBaseUrl()
Get/set base url
public
setBaseUrl([string $newUrl = null ]) : string
Parameters
- $newUrl : string = null
-
New base url
Return values
string —Current or new base url
setFileLocation()
Get/set output file path
public
setFileLocation([string $newLocation = null ]) : string
Parameters
- $newLocation : string = null
-
New path
Return values
string —Current or new path
setVerbose()
Get/set verbose callback
public
setVerbose([callable|null $newMode = null ]) : callable|null
Parameters
- $newMode : callable|null = null
-
Callback for writing verbose messages (or null to disable them)
Return values
callable|null —Current verbose callback (null if disabled)
buildIndex()
Write a sitemap index if requested.
protected
buildIndex(array<string|int, mixed> $sitemaps) : void
Parameters
- $sitemaps : array<string|int, mixed>
-
Sitemaps to add to the index.
Return values
void —generateWithPlugins()
Generate sitemaps from all mandatory and configured plugins
protected
generateWithPlugins() : array<string|int, mixed>
Return values
array<string|int, mixed> —getBaseSitemapIndexUrl()
Get the base URL for sitemap index files
protected
getBaseSitemapIndexUrl() : string
Return values
string —getFilenameForPage()
Get the filename for the specified page number or name.
protected
getFilenameForPage(int|string $page[, bool $includePath = true ]) : string
Parameters
- $page : int|string
-
Page number or name
- $includePath : bool = true
-
Whether to include the path name
Return values
string —getNewSitemap()
Get a fresh Sitemap object.
protected
getNewSitemap() : Sitemap
Return values
Sitemap —getNewSitemapIndex()
Get a fresh SitemapIndex object.
protected
getNewSitemapIndex() : SitemapIndex
Return values
SitemapIndex —getPlugin()
Create and setup a plugin
protected
getPlugin(string $pluginName) : GeneratorPluginInterface
Parameters
- $pluginName : string
-
Plugin name
Return values
GeneratorPluginInterface —getSitemapLanguages()
Get languages for a sitemap
protected
getSitemapLanguages(array<string|int, mixed> $locales) : array<string|int, mixed>
Returns an array with sitemap languages as keys and VuFind languages as values.
Parameters
- $locales : array<string|int, mixed>
-
Enabled VuFind locales
Return values
array<string|int, mixed> —getTime()
Get the current microtime, formatted to a number.
protected
getTime() : float
Return values
float —verboseMsg()
Write a verbose message (if configured to do so)
protected
verboseMsg(string $msg) : void
Parameters
- $msg : string
-
Message to display