public function XmlSitemapWriter::__construct in XML sitemap 2.x
Same name and namespace in other branches
- 8 src/XmlSitemapWriter.php \Drupal\xmlsitemap\XmlSitemapWriter::__construct()
Constructors and XmlSitemapWriter object.
Parameters
\Drupal\xmlsitemap\XmlSitemapInterface $sitemap: The XML sitemap.
int|string $page: The current page of the sitemap being generated.
Throws
\InvalidArgumentException If the page is invalid.
\Drupal\xmlsitemap\XmlSitemapGenerationException If the file URI cannot be opened.
File
- src/
XmlSitemapWriter.php, line 62
Class
- XmlSitemapWriter
- Extended class for writing XML sitemap files.
Namespace
Drupal\xmlsitemapCode
public function __construct(XmlSitemapInterface $sitemap, $page) {
if ($page !== 'index' && !filter_var($page, FILTER_VALIDATE_INT)) {
throw new \InvalidArgumentException("Invalid XML sitemap page {$page}.");
}
$this->sitemap = $sitemap;
$this->page = $page;
$this->uri = xmlsitemap_sitemap_get_file($sitemap, $page);
$this
->openUri($this->uri);
}