You are here

public function XmlSitemapWriter::endDocument in XML sitemap 8

Same name and namespace in other branches
  1. 2.x src/XmlSitemapWriter.php \Drupal\xmlsitemap\XmlSitemapWriter::endDocument()

Ends an XML document.

Return value

bool Returns TRUE on success.

Throws

XmlSitemapGenerationException

File

src/XmlSitemapWriter.php, line 256

Class

XmlSitemapWriter
Extended class for writing XML sitemap files.

Namespace

Drupal\xmlsitemap

Code

public function endDocument() {
  $return = parent::endDocument();
  if (!$return) {
    throw new XmlSitemapGenerationException("Unknown error occurred while writing to file {$this->uri}.");
  }
  if (xmlsitemap_var('gz')) {
    $file_gz = $this->uri . '.gz';
    file_put_contents($file_gz, gzencode(file_get_contents($this->uri), 9));
  }
  return $return;
}