DBFarmRole::GetFarmObject PHP Method

GetFarmObject() public method

Returns DBFarm Object
public GetFarmObject ( ) : DBFarm
return DBFarm
    public function GetFarmObject()
    {
        if (!$this->DBFarm) {
            $this->DBFarm = DBFarm::LoadByID($this->FarmID);
        }
        return $this->DBFarm;
    }

Usage Example

示例#1
0
 /**
  * Constructor
  *
  * @param    string     $platform    Platform
  * @param    DBFarmRole $DBFarmRole  optional Farm Role object
  * @param    int        $index       optional Server index within the Farm Role scope
  * @param    string     $role_id     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'));
 }
All Usage Examples Of DBFarmRole::GetFarmObject