mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 17:45:40 +03:00
[HaveIBeenPwnedBridge] Add item limit parameter, set default limit to 20 (#1219)
* Add `item_limit` parameter to allow user to control number of item returned by bridge. Suggested by @triatic and @somini (code).
This commit is contained in:
parent
be27bc9250
commit
e032705c9a
1 changed files with 15 additions and 0 deletions
|
@ -13,6 +13,11 @@ class HaveIBeenPwnedBridge extends BridgeAbstract {
|
|||
'Date added to HIBP' => 'dateAdded',
|
||||
),
|
||||
'defaultValue' => 'dateAdded',
|
||||
),
|
||||
'item_limit' => array(
|
||||
'name' => 'Limit number of returned items',
|
||||
'type' => 'number',
|
||||
'defaultValue' => 20,
|
||||
)
|
||||
));
|
||||
|
||||
|
@ -109,6 +114,12 @@ class HaveIBeenPwnedBridge extends BridgeAbstract {
|
|||
*/
|
||||
private function createItems() {
|
||||
|
||||
$limit = $this->getInput('item_limit');
|
||||
|
||||
if ($limit < 1) {
|
||||
$limit = 20;
|
||||
}
|
||||
|
||||
foreach ($this->breaches as $breach) {
|
||||
$item = array();
|
||||
|
||||
|
@ -118,6 +129,10 @@ class HaveIBeenPwnedBridge extends BridgeAbstract {
|
|||
$item['content'] = $breach['content'];
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
if (count($this->items) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue