Beispiel #1
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Model\Type\AbstractType::toPhp()
  */
 public function toPhp($value)
 {
     $objectAccess = new ObjectAccess();
     if ($value !== null) {
         $objectAccess->unserialize($value);
     }
     return $objectAccess;
 }
 /**
  * Constructor
  *
  * @param array $subtotals       The subtotal fields in exact order
  * @param array $aggregateFields The fields which is used for aggregation
  */
 public function __construct(array $subtotals, array $aggregateFields)
 {
     parent::__construct();
     $this->subtotals = [];
     $i = 0;
     foreach ($subtotals as $k => $v) {
         if (is_numeric($k)) {
             $this->subtotals[$i] = $v;
         } else {
             $this->subtotals[$i] = $k;
             $this->associatedFields[$i] = $v;
         }
         $i++;
     }
     $this->aggregateFields = $aggregateFields;
 }
Beispiel #3
0
 /**
  * Setup scaling times for DateAndTime scaling metrics
  *
  * @throws ModelException
  */
 public function setupScalingTimes()
 {
     if (ScalingMetric::METRIC_DATE_AND_TIME_ID === $this->metricId) {
         FarmRoleScalingTime::deleteByFarmRoleId($this->farmRoleId);
         foreach ($this->settings as $key => $setting) {
             if (is_array($setting[static::WEEK_DAYS])) {
                 $setting[static::WEEK_DAYS] = ucwords(implode(', ', $setting[static::WEEK_DAYS]));
             }
             $start = $setting[static::START_TIME];
             $end = $setting[static::END_TIME];
             //create farm role scaling time
             $scalingTime = new FarmRoleScalingTime();
             $scalingTime->farmRoleId = $this->farmRoleId;
             $scalingTime->startTime = (int) $this->convertTime($start, static::SCALING_TIME_FORMAT);
             $scalingTime->endTime = (int) $this->convertTime($end, static::SCALING_TIME_FORMAT);
             $scalingTime->daysOfWeek = $setting[static::WEEK_DAYS];
             $scalingTime->instancesCount = $setting[static::INSTANCES_COUNT];
             $setting[static::START_TIME] = $this->convertTime($start, static::SETTINGS_TIME_FORMAT);
             $setting[static::END_TIME] = $this->convertTime($end, static::SETTINGS_TIME_FORMAT);
             $setting['id'] = "{$scalingTime->startTime}:{$scalingTime->endTime}:{$scalingTime->daysOfWeek}:{$scalingTime->instancesCount}";
             $scalingTime->save();
             $this->settings->offsetSet($key, $setting);
         }
     }
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  * @see ObjectAccess::getIterator()
  */
 public function getIterator()
 {
     if (!$this->loaded) {
         $this->load();
     }
     return parent::getIterator();
 }