/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { parent::save(); if (!empty($this->_settings)) { $this->_settings->save(); } }
/** * {@inheritdoc} * @see \Scalr\Model\AbstractEntity::save() */ public function save() { if (empty($this->emails)) { throw new AnalyticsException(sprintf("Email must be set for the %s.", get_class($this))); } parent::save(); }
/** * {@inheritdoc} * @see \Scalr\Model\AbstractEntity::save() */ public function save() { if ($this->{static::ENTITY_VALUE_FIELD_NAME} === null) { $this->delete(); } else { parent::save(); } }
/** * {@inheritdoc} * @see \Scalr\Model\AbstractEntity::save() */ public function save() { if (empty($this->eventId)) { throw new ModelException(sprintf("eventId must be set for %s before saving.", get_class($this))); } else { if (empty($this->ccId)) { throw new ModelException(sprintf("ccId must be set for %s before saving.", get_class($this))); } } parent::save(); }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { parent::save(); foreach ($this->_properties as $property) { if ($property->value == false) { $property->delete(); } else { $property->save(); } } }
public function save() { $this->variables = []; $matches = []; $text = preg_replace('/(\\\\%)/si', '$$scalr$$', $this->content); preg_match_all("/\\%([^\\%\\s]+)\\%/si", $text, $matches); $builtin = array_keys(\Scalr_Scripting_Manager::getScriptingBuiltinVariables()); foreach ($matches[1] as $var) { if (!in_array($var, $builtin)) { $this->variables[$var] = ucwords(str_replace("_", " ", $var)); } } parent::save(); }
/** * {@inheritdoc} * @see \Scalr\Model\AbstractEntity::save() */ public function save() { //Checks data integrity. $criteria = [['name' => $this->name]]; if ($this->ccId) { $criteria[] = ['ccId' => ['$ne' => $this->ccId]]; } //The name of the cost centre should be unique withing the global $item = CostCentreEntity::findOne($criteria); if ($item) { throw new AnalyticsException(sprintf('A Cost Center with this name already exists. Please choose another name.')); } parent::save(); if ($this->ccId && \Scalr::getContainer()->analytics->enabled) { \Scalr::getContainer()->analytics->tags->syncValue($this->accountId ?: 0, \Scalr\Stats\CostAnalytics\Entity\TagEntity::TAG_ID_COST_CENTRE, $this->ccId, $this->name); } }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { $this->setupScalingTimes(); parent::save(); }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { $this->changed = microtime(); if (empty($this->id)) { $this->createdById = $this->changedById; $this->added = new DateTime(); $this->status = FARM_STATUS::TERMINATED; if (empty($this->settings[FarmSetting::TIMEZONE])) { $this->settings[FarmSetting::TIMEZONE] = date_default_timezone_get(); } $this->settings[FarmSetting::CRYPTO_KEY] = \Scalr::GenerateRandomKey(40); /* @var $governance Governance */ $governance = Governance::findPk($this->envId, Governance::CATEGORY_GENERAL, Governance::GENERAL_LEASE); if (!empty($governance) && $governance->enabled) { $this->settings[FarmSetting::LEASE_STATUS] = 'Active'; } //TODO: unused field $this->region = Aws::REGION_US_EAST_1; } parent::save(); if (!empty($this->_settings)) { $this->_settings->save(); } }
public function save() { $this->db()->BeginTrans(); try { parent::save(); $this->db()->Execute("DELETE FROM `role_behaviors` WHERE `role_id` = ?", [$this->id]); $sql = $args = []; foreach ($this->getBehaviors() as $behavior) { $sql[] = '(?, ?)'; $args = array_merge($args, [$this->id, $behavior]); } if (count($sql)) { $this->db()->Execute("INSERT INTO `role_behaviors` (`role_id`, `behavior`) VALUES " . join(', ', $sql), $args); } $this->db()->CommitTrans(); } catch (\Exception $e) { $this->db()->RollbackTrans(); throw $e; } }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { $this->setupRole(); $this->setupAlias(); $this->setupScaling(); $this->setupBehaviors(); $this->setupPolling(); parent::save(); $this->setupAnalytics(); if (!empty($this->_settings)) { $this->_settings->save(); } }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { $this->changed = microtime(); $db = $this->db(); try { $db->BeginTrans(); if (empty($this->id)) { $this->ownerId = $this->changedById; $this->settings[FarmSetting::CREATED_BY_ID] = $this->ownerId; $this->settings[FarmSetting::CREATED_BY_EMAIL] = User::findPk($this->ownerId)->email; $this->added = new DateTime(); $this->status = FARM_STATUS::TERMINATED; if (empty($this->settings[FarmSetting::TIMEZONE])) { $this->settings[FarmSetting::TIMEZONE] = date_default_timezone_get(); } $this->settings[FarmSetting::CRYPTO_KEY] = \Scalr::GenerateRandomKey(40); /* @var $governance Governance */ $governance = Governance::findPk($this->envId, Governance::CATEGORY_GENERAL, Governance::GENERAL_LEASE); if (!empty($governance) && $governance->enabled) { $this->settings[FarmSetting::LEASE_STATUS] = 'Active'; } //TODO: unused field $this->region = Aws::REGION_US_EAST_1; } parent::save(); if (!empty($this->_settings)) { $this->_settings->save(); } if (isset($this->_teamsChanged)) { $this->saveTeams($this->_teams); $this->_teamsChanged = false; } $db->CommitTrans(); } catch (Exception $e) { $db->RollbackTrans(); throw $e; } }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { parent::save(); if (!empty($this->_properties)) { $this->_properties->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 $hash = self::calculateHash($this->envId, $this->id, $this->platform, $this->cloudLocation); if (!$this->hash) { $this->hash = $hash; } else { if ($this->hash != $hash) { throw new Exception('Hash are mismatched in entity Image'); } } parent::save(); }
/** * Creates and save entity to DB^ keep entity to delete after test * * @param AbstractEntity $entity * @param array $data * * @return AbstractEntity */ public function createEntity(AbstractEntity $entity, array $data) { foreach ($entity->getIterator() as $property => $_) { if (isset($data[$property])) { $entity->{$property} = $data[$property]; } } $entity->save(); $key = []; foreach ($entity->getIterator()->getPrimaryKey() as $position => $property) { $key[$position] = $entity->{$property}; } static::$testData[get_class($entity)][] = $key; return $entity; }
/** * {@inheritdoc} * @see AbstractEntity::save() */ public function save() { try { $this->db()->BeginTrans(); parent::save(); if (!empty($this->_properties)) { $this->_properties->save(); } $this->db()->CommitTrans(); } catch (Exception $e) { $this->db()->RollbackTrans(); throw $e; } }
/** * Saves changes, if script already exists, or saves new script * * @throws ModelException */ public function save() { $id = $this->id; $this->dtChanged = new \DateTime(); parent::save(); if (!$id) { // we should create first version $version = new ScriptVersion(); $version->scriptId = $this->id; $version->version = 1; $version->content = ''; $version->changedById = $this->createdById; $version->changedByEmail = $this->createdByEmail; $version->save(); } }
public function save() { $this->variables = []; $variables = Script::fetchVariables($this->content); if (!empty($variables)) { $builtin = array_keys(\Scalr_Scripting_Manager::getScriptingBuiltinVariables()); foreach ($variables as $var) { if (!in_array($var, $builtin)) { $this->variables[$var] = ucwords(str_replace("_", " ", $var)); } } } parent::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(); }
/** * Creates and save entity to DB, keeps entity to delete after test * * @param AbstractEntity $entity * @param array $data * @param int $priority * * @return AbstractEntity * @throws \Scalr\Exception\ModelException */ public static function createEntity(AbstractEntity $entity, array $data, $priority = 0) { foreach ($entity->getIterator() as $property => $_) { if (isset($data[$property])) { $entity->{$property} = $data[$property]; } } $entity->save(); $key = []; foreach ($entity->getIterator()->getPrimaryKey() as $position => $property) { $key[$position] = $entity->{$property}; } static::toDelete(get_class($entity), $key, $priority); return $entity; }