From 5779f641c01d209d3a21df8a2b9ce8fa421a36b2 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Mon, 15 Oct 2018 17:33:19 +0200 Subject: [PATCH] [FacebookBridge] Add option to limit number of returned items This commit adds a new optional parameter 'limit' which can be used to limit the number of items returned by this bridge (i.e. '&limit=10') As requested in #669 --- bridges/FacebookBridge.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bridges/FacebookBridge.php b/bridges/FacebookBridge.php index 3718b2e2..e44e3caa 100644 --- a/bridges/FacebookBridge.php +++ b/bridges/FacebookBridge.php @@ -41,6 +41,15 @@ class FacebookBridge extends BridgeAbstract { 'exampleValue' => 'https://www.facebook.com/groups/743149642484225', 'title' => 'Insert group name or facebook group URL' ) + ), + 'global' => array( + 'limit' => array( + 'name' => 'Limit', + 'type' => 'number', + 'required' => false, + 'title' => 'Specify the number of items to return (default: -1)', + 'defaultValue' => -1 + ) ) ); @@ -117,6 +126,12 @@ class FacebookBridge extends BridgeAbstract { } + $limit = $this->getInput('limit') ?: -1; + + if($limit > 0 && count($this->items) > $limit) { + $this->items = array_slice($this->items, 0, $limit); + } + } #region Group