Scalr_Scripting_GlobalVariables::listServerGlobalVariables PHP Method

listServerGlobalVariables() public static method

public static listServerGlobalVariables ( DBServer $dbServer, $includeSystem = false, AbstractServerEvent $event = null )
$dbServer DBServer
$event AbstractServerEvent
    public static function listServerGlobalVariables(DBServer $dbServer, $includeSystem = false, AbstractServerEvent $event = null)
    {
        $retval = array();
        if ($includeSystem) {
            $variables = $dbServer->GetScriptingVars();
            if ($event) {
                if ($event->DBServer) {
                    foreach ($event->DBServer->GetScriptingVars() as $k => $v) {
                        $variables["event_{$k}"] = $v;
                    }
                }
                foreach ($event->GetScriptingVars() as $k => $v) {
                    $variables[$k] = $event->{$v};
                }
                if (isset($event->params) && is_array($event->params)) {
                    foreach ($event->params as $k => $v) {
                        $variables[$k] = $v;
                    }
                }
                $variables['event_name'] = $event->GetName();
            }
            $formats = \Scalr::config("scalr.system.global_variables.format");
            foreach ($variables as $name => $value) {
                $name = "SCALR_" . strtoupper($name);
                $value = trim($value);
                if (isset($formats[$name])) {
                    $value = @sprintf($formats[$name], $value);
                }
                $private = strpos($name, 'SCALR_EVENT_') === 0 ? 1 : 0;
                $retval[] = (object) array('name' => $name, 'value' => $value, 'private' => $private, 'system' => 1);
            }
        }
        try {
            $globalVariables = new Scalr_Scripting_GlobalVariables($dbServer->GetEnvironmentObject()->clientId, $dbServer->envId, ScopeInterface::SCOPE_SERVER);
            $vars = $globalVariables->listVariables($dbServer->GetFarmRoleObject()->RoleID, $dbServer->farmId, $dbServer->farmRoleId, $dbServer->serverId);
            foreach ($vars as $v) {
                $retval[] = (object) $v;
            }
        } catch (Exception $e) {
        }
        return $retval;
    }

Usage Example

示例#1
0
文件: Msg.php 项目: mheydt/scalr
 public function setGlobalVariables(DBServer $dbServer, $includeSystem = false, AbstractServerEvent $event = null)
 {
     $this->globalVariables = Scalr_Scripting_GlobalVariables::listServerGlobalVariables($dbServer, $includeSystem, $event);
 }
All Usage Examples Of Scalr_Scripting_GlobalVariables::listServerGlobalVariables