Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions bundle/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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');

Expand All @@ -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');
}


}
1 change: 1 addition & 0 deletions bundle/Resources/config/default_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ parameters:
label: 'Twitter - Image'
default_pattern: "<image|picture>"
icon: 'twitter-square'
nova_ezseo.default.packet_max: 1000