mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-12-18 00:43:19 +03:00
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
This commit is contained in:
parent
4f5a492dde
commit
4323a11667
1 changed files with 19 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue