Scalr\Model\Entity\Image::getEnvironment PHP Метод

getEnvironment() публичный Метод

Return NULL, if image is owned by admin
public getEnvironment ( ) : null | Scalr_Environmen\Scalr_Environment
Результат null | Scalr_Environmen\Scalr_Environment
    public function getEnvironment()
    {
        if (!$this->envId) {
            return NULL;
        }
        if (!$this->_environment) {
            $this->_environment = new Scalr_Environment();
            $this->_environment->loadById($this->envId);
        }
        return $this->_environment;
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::RemoveServerSnapshot()
  */
 public function RemoveServerSnapshot(Image $image)
 {
     if (!$image->getEnvironment()) {
         return true;
     }
     $gce = $this->getClient($image->getEnvironment());
     try {
         $projectId = $image->getEnvironment()->keychain(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID];
         $imageId = str_replace("{$projectId}/images/", "", $image->id);
         $gce->images->delete($projectId, $imageId);
     } catch (Exception $e) {
         if (stristr($e->getMessage(), "was not found")) {
             return true;
         } else {
             throw $e;
         }
     }
     return true;
 }
All Usage Examples Of Scalr\Model\Entity\Image::getEnvironment