function xmlsitemap_sitemap_get_max_filesize in XML sitemap 8
Same name and namespace in other branches
- 6.2 xmlsitemap.module \xmlsitemap_sitemap_get_max_filesize()
- 7.2 xmlsitemap.module \xmlsitemap_sitemap_get_max_filesize()
- 2.x xmlsitemap.module \xmlsitemap_sitemap_get_max_filesize()
Find the maximum file size of all a sitemap's XML files.
Parameters
\Drupal\xmlsitemap\XmlSitemapInterface $sitemap: The XML sitemap object.
Return value
int Maximum file size in the directory.
Related topics
1 call to xmlsitemap_sitemap_get_max_filesize()
- XmlSitemapGenerator::regenerateBatchGenerate in src/
XmlSitemapGenerator.php - Batch callback; generate all pages of a sitemap.
File
- ./
xmlsitemap.module, line 424 - xmlsitemap XML sitemap
Code
function xmlsitemap_sitemap_get_max_filesize(XmlSitemapInterface $sitemap) {
$dir = xmlsitemap_get_directory($sitemap);
$sitemap
->setMaxFileSize(0);
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
$file_system = \Drupal::service('file_system');
$files = $file_system
->scanDirectory($dir, '/\\.xml$/');
foreach ($files as $file) {
$sitemap
->setMaxFileSize(max($sitemap
->getMaxFileSize(), filesize($file->uri)));
}
return $sitemap
->getMaxFileSize();
}