forked from blallo/rss-bridge
[Bridge] Pass 'queriedContext' as parameter to 'setInputs'
This makes clear that 'setInputs' depends on the 'queriedContext'
This commit is contained in:
parent
d1ff23c7ba
commit
a8883523f4
1 changed files with 15 additions and 15 deletions
|
@ -243,7 +243,8 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setInputs(array $inputs){
|
protected function setInputs(array $inputs, $queriedContext){
|
||||||
|
// Import and assign all inputs to their context
|
||||||
foreach($inputs as $name => $value){
|
foreach($inputs as $name => $value){
|
||||||
foreach(static::PARAMETERS as $context => $set){
|
foreach(static::PARAMETERS as $context => $set){
|
||||||
if(array_key_exists($name, static::PARAMETERS[$context])){
|
if(array_key_exists($name, static::PARAMETERS[$context])){
|
||||||
|
@ -253,21 +254,19 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply default values to missing data
|
// Apply default values to missing data
|
||||||
$contexts = array($this->queriedContext);
|
$contexts = array($queriedContext);
|
||||||
if(array_key_exists('global', static::PARAMETERS)){
|
if(array_key_exists('global', static::PARAMETERS)){
|
||||||
$contexts[] = 'global';
|
$contexts[] = 'global';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($contexts as $context){
|
foreach($contexts as $context){
|
||||||
foreach(static::PARAMETERS[$context] as $name => $properties){
|
foreach(static::PARAMETERS[$context] as $name => $properties){
|
||||||
if(!isset($properties['type'])){
|
|
||||||
$type = 'text';
|
|
||||||
} else {
|
|
||||||
$type = $properties['type'];
|
|
||||||
}
|
|
||||||
if(isset($this->inputs[$context][$name]['value'])){
|
if(isset($this->inputs[$context][$name]['value'])){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type = isset($properties['type']) ? $properties['type'] : 'text';
|
||||||
|
|
||||||
switch($type){
|
switch($type){
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
if(!isset($properties['defaultValue'])){
|
if(!isset($properties['defaultValue'])){
|
||||||
|
@ -301,20 +300,21 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
foreach(static::PARAMETERS['global'] as $name => $properties){
|
foreach(static::PARAMETERS['global'] as $name => $properties){
|
||||||
if(isset($inputs[$name])){
|
if(isset($inputs[$name])){
|
||||||
$value = $inputs[$name];
|
$value = $inputs[$name];
|
||||||
}else if(isset($properties['value'])){
|
} elseif (isset($properties['value'])){
|
||||||
$value = $properties['value'];
|
$value = $properties['value'];
|
||||||
}else{
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$this->inputs[$this->queriedContext][$name]['value'] = $value;
|
$this->inputs[$queriedContext][$name]['value'] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only keep guessed context parameters values
|
// Only keep guessed context parameters values
|
||||||
if(!isset($this->inputs[$this->queriedContext])){
|
if(isset($this->inputs[$queriedContext])){
|
||||||
$this->inputs[$this->queriedContext] = array();
|
$this->inputs = array($queriedContext => $this->inputs[$queriedContext]);
|
||||||
|
} else {
|
||||||
|
$this->inputs = array();
|
||||||
}
|
}
|
||||||
$this->inputs = array($this->queriedContext=>$this->inputs[$this->queriedContext]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getQueriedContext(array $inputs){
|
protected function getQueriedContext(array $inputs){
|
||||||
|
@ -390,7 +390,7 @@ abstract class BridgeAbstract implements BridgeInterface {
|
||||||
$this->returnClientError('Mixed context parameters');
|
$this->returnClientError('Mixed context parameters');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setInputs($inputs);
|
$this->setInputs($inputs, $this->queriedContext);
|
||||||
|
|
||||||
$this->collectData();
|
$this->collectData();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue