public function _scope($from, $to, $action)
{
switch ($action) {
case static::ACT_CONVERT_TO_OBJECT:
/* @var $from Entity\ScalingMetric */
$to->scope = $from->getScope();
break;
case static::ACT_CONVERT_TO_ENTITY:
/* @var $to Entity\ScalingMetric */
switch ($from->scope) {
case ScopeInterface::SCOPE_SCALR:
break;
case ScopeInterface::SCOPE_ENVIRONMENT:
$to->envId = $this->controller->getEnvironment()->id;
$to->accountId = $this->controller->getUser()->getAccountId();
break;
default:
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, 'Unexpected scope value');
}
break;
case static::ACT_GET_FILTER_CRITERIA:
if (empty($from->scope)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, 'Missed scope value');
}
return $this->controller->getScopeCriteria($from->scope, true);
}
}