diff --git a/bundle/Controller/SitemapController.php b/bundle/Controller/SitemapController.php index edee4df..92ec33d 100644 --- a/bundle/Controller/SitemapController.php +++ b/bundle/Controller/SitemapController.php @@ -90,7 +90,7 @@ public function indexAction(): Response $sitemap->formatOutput = true; // create an index if we are greater than th PACKET_MAX - if ($resultCount > static::PACKET_MAX) { + if ($resultCount > $this->getPacketMax()) { $root = $sitemap->createElement('sitemapindex'); $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $sitemap->appendChild($root); @@ -125,8 +125,8 @@ public function pageAction(int $page = 1): Response $root->setAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); $sitemap->appendChild($root); $query = $this->getQuery(); - $query->limit = static::PACKET_MAX; - $query->offset = static::PACKET_MAX * ($page - 1); + $query->limit = $this->getPacketMax(); + $query->offset = $this->getPacketMax() * ($page - 1); $searchService = $this->getRepository()->getSearchService(); @@ -174,7 +174,7 @@ protected function fillSitemap(DOMDocument $sitemap, DOMElement $root, SearchRes */ protected function fillSitemapIndex(DOMDocument $sitemap, int $numberOfResults, DOMElement $root): void { - $numberOfPage = (int) ceil($numberOfResults / static::PACKET_MAX); + $numberOfPage = (int) ceil($numberOfResults / $this->getPacketMax()); for ($sitemapNumber = 1; $sitemapNumber <= $numberOfPage; ++$sitemapNumber) { $sitemapElt = $sitemap->createElement('sitemap'); @@ -200,4 +200,14 @@ protected function fillSitemapIndex(DOMDocument $sitemap, int $numberOfResults, $root->appendChild($sitemapElt); } } + + /** + * @return int + */ + public function getPacketMax() + { + return $this->getConfigResolver()->getParameter('packet_max', 'nova_ezseo'); + } + + } diff --git a/bundle/Resources/config/default_settings.yml b/bundle/Resources/config/default_settings.yml index ea3db65..679d02a 100644 --- a/bundle/Resources/config/default_settings.yml +++ b/bundle/Resources/config/default_settings.yml @@ -80,3 +80,4 @@ parameters: label: 'Twitter - Image' default_pattern: "" icon: 'twitter-square' + nova_ezseo.default.packet_max: 1000