ServerCreateInfo::__construct PHP Method

__construct() public method

Constructor
public __construct ( string $platform, DBFarmRole $DBFarmRole = null, integer $index = null, string $role_id = null )
$platform string Platform
$DBFarmRole DBFarmRole optional Farm Role object
$index integer optional Server index within the Farm Role scope
$role_id string optional Identifier of the Role
    public function __construct($platform, DBFarmRole $DBFarmRole = null, $index = null, $role_id = null)
    {
        $this->platform = $platform;
        $this->dbFarmRole = $DBFarmRole;
        $this->index = $index;
        $this->roleId = $role_id === null ? $this->dbFarmRole->RoleID : $role_id;
        if ($DBFarmRole) {
            $this->envId = $DBFarmRole->GetFarmObject()->EnvID;
        }
        //Refletcion
        $Reflect = new ReflectionClass(DBServer::$platformPropsClasses[$this->platform]);
        foreach ($Reflect->getConstants() as $k => $v) {
            $this->platformProps[] = $v;
        }
        if ($DBFarmRole) {
            if (PlatformFactory::isOpenstack($this->platform)) {
                $this->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
            } elseif (PlatformFactory::isCloudstack($this->platform)) {
                $this->SetProperties(array(CLOUDSTACK_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
            } else {
                switch ($this->platform) {
                    case SERVER_PLATFORMS::GCE:
                        $this->SetProperties(array(GCE_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
                        break;
                    case SERVER_PLATFORMS::EC2:
                        $this->SetProperties(array(EC2_SERVER_PROPERTIES::REGION => $DBFarmRole->CloudLocation));
                        break;
                }
            }
        }
        $this->SetProperties(array(SERVER_PROPERTIES::SZR_VESION => '0.20.0'));
    }