Scalr_Scripting_GlobalVariables::listVariables PHP Méthode

listVariables() public méthode

public listVariables ( $roleId, $farmId, $farmRoleId, $serverId = '' )
    public function listVariables($roleId = 0, $farmId = 0, $farmRoleId = 0, $serverId = '')
    {
        $retval = array();
        foreach ($this->_getValues($roleId, $farmId, $farmRoleId, $serverId) as $name => $var) {
            if (strtolower(substr($name, 0, 9)) == 'scalr_ui_') {
                continue;
            }
            $value = !empty($var['current']) ? $var['current']['value'] : $var['default']['value'];
            if ($value == '') {
                $value = $var['lastValue'];
            }
            if (!empty($var['locked']) && $var['locked']['flagFinal'] == 1) {
                $value = $var['locked']['value'];
            }
            if (!empty($var['locked']) && $var['locked']['format']) {
                $value = @sprintf($var['locked']['format'], $value);
            } else {
                if (!empty($var['current']) && $var['current']['format']) {
                    $value = @sprintf($var['current']['format'], $value);
                }
            }
            $retval[] = array('name' => $name, 'value' => $value, 'private' => !empty($var['locked']) && $var['locked']['flagHidden'] == 1 || !empty($var['current']) && $var['current']['flagHidden'] == 1 ? 1 : 0);
        }
        return $retval;
    }

Usage Example

 public function ListGlobalVariables()
 {
     $ResponseDOMDocument = $this->CreateResponse();
     $configNode = $ResponseDOMDocument->createElement("variables");
     $globalVariables = new Scalr_Scripting_GlobalVariables($this->DBServer->envId, Scalr_Scripting_GlobalVariables::SCOPE_FARMROLE);
     $vars = $globalVariables->listVariables($this->DBServer->roleId, $this->DBServer->farmId, $this->DBServer->farmRoleId);
     foreach ($vars as $key => $value) {
         $settingNode = $ResponseDOMDocument->createElement("variable", $value);
         $settingNode->setAttribute("name", $key);
         $configNode->appendChild($settingNode);
     }
     $formats = \Scalr::config("scalr.system.global_variables.format");
     foreach ($this->DBServer->GetScriptingVars() as $name => $value) {
         $name = "SCALR_" . strtoupper($name);
         $value = trim($value);
         if (isset($formats[$name])) {
             $value = @sprintf($formats[$name], $value);
         }
         $settingNode = $ResponseDOMDocument->createElement("variable", $value);
         $settingNode->setAttribute("name", $name);
         $configNode->appendChild($settingNode);
     }
     $ResponseDOMDocument->documentElement->appendChild($configNode);
     return $ResponseDOMDocument;
 }
All Usage Examples Of Scalr_Scripting_GlobalVariables::listVariables