From 4323a11667806e0f8f3316f426d3834d97ad545d Mon Sep 17 00:00:00 2001 From: sysadminstory Date: Wed, 13 Sep 2023 00:16:11 +0200 Subject: [PATCH] doc : clarification detectParameters function and test (#3666) * doc : clarification detectParameters function - clarification about the return value of the detectParameters function - add info about the constant TEST_DETECT_PARAMETERS to allow automatest test of the function detectParameters * doc : clarification detectParameters function Add reference to the findFeed action to encourage the implenentation of the detectParameters function * doc : clarification detectParameters function Add commas to improve reading * doc : clarification detectParameters function - fix link --- docs/05_Bridge_API/02_BridgeAbstract.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/05_Bridge_API/02_BridgeAbstract.md b/docs/05_Bridge_API/02_BridgeAbstract.md index 120361be..12d24bdc 100644 --- a/docs/05_Bridge_API/02_BridgeAbstract.md +++ b/docs/05_Bridge_API/02_BridgeAbstract.md @@ -437,9 +437,9 @@ If no icon is specified by the bridge, RSS-Bridge will use a default location: ` # detectParameters The `detectParameters` function takes a URL and attempts to extract a valid set of parameters for the current bridge. -If the passed URL is valid for this bridge the function should return an array of parameter -> value pairs that can be used by this bridge, or an empty array if the bridge requires no parameters. If the URL is not relevant for this bridge the function should return `null`. +If the passed URL is valid for this bridge, the function should return an array of parameter -> value pairs that can be used by this bridge, including context if available, or an empty array if the bridge requires no parameters. If the URL is not relevant for this bridge, the function should return `null`. -**Notice:** Implementing this function is optional. By default **RSS-Bridge** tries to match the supplied URL to the `URI` constant defined in the bridge which may be enough for bridges without any parameters defined. +**Notice:** Implementing this function is optional. By default, **RSS-Bridge** tries to match the supplied URL to the `URI` constant defined in the bridge, which may be enough for bridges without any parameters defined. ```PHP public function detectParameters($url){ @@ -455,6 +455,23 @@ public function detectParameters($url){ } ``` +**Notice:** This function is also used by the [findFeed](../04_For_Developers/04_Actions.md#findfeed) action. This action allows an user to get a list of all feeds corresponding to an URL. + +You can implement automated tests for the `detectParameters` function by adding the `TEST_DETECT_PARAMETERS` constant to your bridge class constant. + +`TEST_DETECT_PARAMETERS` is an array, with as key the URL passed to the `detectParameters`function and as value, the array of parameters returned by `detectParameters` + +```PHP + const TEST_DETECT_PARAMETERS = [ + 'https://www.instagram.com/metaverse' => ['context' => 'Username', 'u' => 'metaverse'], + 'https://instagram.com/metaverse' => ['context' => 'Username', 'u' => 'metaverse'], + 'http://www.instagram.com/metaverse' => ['context' => 'Username', 'u' => 'metaverse'], + ]; +``` + +**Notice:** Adding this constant is optional. If the constant is not present, no automated test will be executed. + + *** # Helper Methods