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

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

public save ( )
    public function save()
    {
        if ($this->platform == \SERVER_PLATFORMS::GCE || $this->platform == \SERVER_PLATFORMS::AZURE) {
            $this->cloudLocation = '';
        }
        // image on GCE or Azure doesn't require cloudLocation
        parent::save();
    }

Usage Example

Пример #1
0
 protected function run2()
 {
     $cnt = 0;
     $images = $this->db->GetAll('SELECT ri.*, r.env_id FROM role_images ri LEFT JOIN roles r ON r.id = ri.role_id');
     foreach ($images as $i) {
         /* @var Image $imObj */
         $i['env_id'] = $i['env_id'] == 0 ? NULL : $i['env_id'];
         $imObj = Image::findOne([['id' => $i['image_id']], ['$or' => [['envId' => $i['env_id']], ['envId' => null]]], ['platform' => $i['platform']], ['cloudLocation' => $i['cloud_location']]]);
         if (!$imObj) {
             $imObj = new Image();
             $imObj->id = $i['image_id'];
             $imObj->envId = $i['env_id'];
             $imObj->platform = $i['platform'];
             $imObj->cloudLocation = $i['cloud_location'];
             $imObj->architecture = $i['architecture'] ? $i['architecture'] : 'x84_64';
             $imObj->osId = $i['os_id'];
             $imObj->isDeprecated = 0;
             $imObj->dtAdded = NULL;
             $imObj->source = Image::SOURCE_MANUAL;
             if ($imObj->envId) {
                 $imObj->checkImage();
             } else {
                 $imObj->status = Image::STATUS_ACTIVE;
             }
             if (is_null($imObj->status)) {
                 $imObj->status = Image::STATUS_ACTIVE;
             }
             if (is_null($imObj->cloudLocation)) {
                 $imObj->cloudLocation = '';
             }
             $imObj->save();
             $cnt++;
         }
     }
     $this->console->notice('Added %s images', $cnt);
 }
All Usage Examples Of Scalr\Model\Entity\Image::save