Skip to content

Commit

Permalink
Add configurable default record count.
Browse files Browse the repository at this point in the history
  • Loading branch information
daedeloth committed Sep 13, 2022
1 parent 79f4a50 commit 330fda3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/CharonConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class CharonConfig extends Singleton
*/
private $htmlPurifierFactory;

/**
* @var int
*/
private $defaultRecordCount = 25;

/**
* @return string
*/
Expand Down Expand Up @@ -65,4 +70,22 @@ public function getHtmlPurifier()

return $this->htmlPurifier;
}

/**
* @param int $records
* @return $this
*/
public function setDefaultRecordCount(int $records)
{
$this->defaultRecordCount = $records;
return $this;
}

/**
* @return int
*/
public function getDefaultRecordCount()
{
return $this->defaultRecordCount;
}
}
3 changes: 2 additions & 1 deletion src/Processors/PaginationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use CatLab\Base\Interfaces\Pagination\PaginationBuilder;
use CatLab\Base\Models\Database\OrderParameter;
use CatLab\Base\Models\Database\DB;
use CatLab\Charon\CharonConfig;
use CatLab\Charon\Exceptions\NotImplementedException;
use CatLab\Charon\Interfaces\Context as ContextContract;
use CatLab\Charon\Interfaces\ResourceCollection;
Expand Down Expand Up @@ -76,7 +77,7 @@ public function processFilters(
// the amount of records we want.
$records = intval($transformer->getRequestResolver()->getRecords($request));
if ($records < 1) {
$records = 10;
$records = CharonConfig::instance()->getDefaultRecordCount();
}
$builder->limit($records);

Expand Down

0 comments on commit 330fda3

Please sign in to comment.