core: Add context hinting for new feeds

RSS-Bridge currently has to guess the queried context from the data
provided by the user. This, however, can cause issues for bridges
that have multiple contexts with conflicting parameters (i.e. none).

This commit adds context hinting to queries via '&context=<context>'
which can be omitted in which case the context is determined as before.
This commit is contained in:
logmanoriginal 2019-06-21 19:08:59 +02:00
parent e2bca5bb05
commit 1591e18027
3 changed files with 19 additions and 4 deletions

View file

@ -194,6 +194,11 @@ abstract class BridgeAbstract implements BridgeInterface {
*/
public function setDatas(array $inputs){
if(isset($inputs['context'])) { // Context hinting (optional)
$this->queriedContext = $inputs['context'];
unset($inputs['context']);
}
if(empty(static::PARAMETERS)) {
if(!empty($inputs)) {
@ -218,8 +223,11 @@ abstract class BridgeAbstract implements BridgeInterface {
);
}
// Guess the paramter context from input data
$this->queriedContext = $validator->getQueriedContext($inputs, static::PARAMETERS);
// Guess the context from input data
if(empty($this->queriedContext)) {
$this->queriedContext = $validator->getQueriedContext($inputs, static::PARAMETERS);
}
if(is_null($this->queriedContext)) {
returnClientError('Required parameter(s) missing');
} elseif($this->queriedContext === false) {