コード例 #1
0
 /**
  * @param \RainLoop\Config\Application $oConfig
  * @param string $sParamName
  * @param string $sConfigSector
  * @param string $sConfigName
  * @param string $sType = 'string'
  * @param callable|null $mStringCallback = null
  */
 public function setConfigFromParams(&$oConfig, $sParamName, $sConfigSector, $sConfigName, $sType = 'string', $mStringCallback = null)
 {
     $sValue = $this->GetActionParam($sParamName, '');
     if ($this->HasActionParam($sParamName)) {
         switch ($sType) {
             default:
             case 'string':
                 $sValue = (string) $sValue;
                 if ($mStringCallback && is_callable($mStringCallback)) {
                     $sValue = call_user_func($mStringCallback, $sValue);
                 }
                 $oConfig->Set($sConfigSector, $sConfigName, (string) $sValue);
                 break;
             case 'dummy':
                 $sValue = (string) $this->GetActionParam('ContactsPdoPassword', APP_DUMMY);
                 if (APP_DUMMY !== $sValue) {
                     $oConfig->Set($sConfigSector, $sConfigName, (string) $sValue);
                 }
                 break;
             case 'int':
                 $iValue = (int) $sValue;
                 $oConfig->Set($sConfigSector, $sConfigName, $iValue);
                 break;
             case 'bool':
                 $oConfig->Set($sConfigSector, $sConfigName, '1' === (string) $sValue);
                 break;
         }
     }
 }