From c2e411ba8230a42515a9b8cb1c9f983f32e04c49 Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Fri, 2 Sep 2016 18:38:07 +0200 Subject: [PATCH] [Bridge] Add function to set inputs --- lib/Bridge.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/Bridge.php b/lib/Bridge.php index 657111af..eea0c90a 100644 --- a/lib/Bridge.php +++ b/lib/Bridge.php @@ -242,6 +242,16 @@ abstract class BridgeAbstract implements BridgeInterface { return true; } + protected function setInputs(array $inputs){ + foreach($inputs as $name => $value){ + foreach(static::PARAMETERS as $context => $set){ + if(array_key_exists($name, static::PARAMETERS[$context])){ + $this->inputs[$context][$name]['value'] = $value; + } + } + } + } + protected function getQueriedContext(){ $queriedContexts=array(); foreach(static::PARAMETERS as $context=>$set){ @@ -308,14 +318,7 @@ abstract class BridgeAbstract implements BridgeInterface { $this->returnClientError('Invalid parameters value(s)'); } - // Populate BridgeAbstract::parameters with sanitized data - foreach($inputs as $name=>$value){ - foreach(static::PARAMETERS as $context=>$set){ - if(array_key_exists($name,static::PARAMETERS[$context])){ - $this->inputs[$context][$name]['value']=$value; - } - } - } + $this->setInputs($inputs); // Guess the paramter context from input data $queriedContext=$this->getQueriedContext();