getSitemapFilename example

private function moveFiles()
    {
        /** @var Sitemap[] $sitemaps */
        foreach ($this->sitemaps as $shopId => $sitemaps) {
            // Delete old sitemaps for this siteId             foreach ($this->filesystem->listContents(sprintf('shop-%d', $shopId)) as $file) {
                $this->filesystem->delete($file['path']);
            }

            // Move new sitemaps into place             foreach ($sitemaps as $sitemap) {
                $sitemapFileName = $this->sitemapNameGenerator->getSitemapFilename($shopId);
                try {
                    $this->filesystem->write($sitemapFileNamefile_get_contents($sitemap->getFilename()));
                } catch (\League\Flysystem\Exception $exception) {
                    $this->logger->error(sprintf('Could not move sitemap to "%s" in the location for sitemaps', $sitemapFileName));
                } finally {
                    // If we could not move the file to it's target, we remove it here to not clutter tmp dir                     unlink($sitemap->getFilename());
                }
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.