PHP Class samdark\sitemap\Sitemap

Author: Alexander Makarov ([email protected])
Show file Open project: samdark/sitemap Class Usage Examples

Public Methods

Method Description
__construct ( string $filePath )
addItem ( string $location, integer $lastModified = null, float $changeFrequency = null, string $priority = null ) Adds a new item to sitemap
getSitemapUrls ( string $baseUrl ) : array Returns an array of URLs written
getWrittenFilePath ( ) : array Get array of generated files
setBufferSize ( integer $number ) Sets number of URLs to be kept in memory before writing it to file.
setMaxUrls ( integer $number ) Sets maximum number of URLs to write in a single file.
setUseIndent ( boolean $value ) Sets if XML should be indented.
write ( ) Finishes writing

Protected Methods

Method Description
validateLocation ( string $location ) Takes a string and validates, if the string is a valid url

Private Methods

Method Description
createNewFile ( ) Creates new file
finishFile ( ) Writes closing tags to current file
flush ( ) Flushes buffer into file
getCurrentFilePath ( ) : string

Method Details

__construct() public method

public __construct ( string $filePath )
$filePath string path of the file to write to

addItem() public method

Adds a new item to sitemap
public addItem ( string $location, integer $lastModified = null, float $changeFrequency = null, string $priority = null )
$location string location item URL
$lastModified integer last modification timestamp
$changeFrequency float change frequency. Use one of self:: constants here
$priority string item's priority (0.0-1.0). Default null is equal to 0.5

getSitemapUrls() public method

Returns an array of URLs written
public getSitemapUrls ( string $baseUrl ) : array
$baseUrl string base URL of all the sitemaps written
return array URLs of sitemaps written

getWrittenFilePath() public method

Get array of generated files
public getWrittenFilePath ( ) : array
return array

setBufferSize() public method

Default is 1000.
public setBufferSize ( integer $number )
$number integer

setMaxUrls() public method

Default is 50000.
public setMaxUrls ( integer $number )
$number integer

setUseIndent() public method

Default is true.
public setUseIndent ( boolean $value )
$value boolean

validateLocation() protected method

Takes a string and validates, if the string is a valid url
protected validateLocation ( string $location )
$location string

write() public method

Finishes writing
public write ( )