public function _target($from, $to, $action)
{
switch ($action) {
case static::ACT_CONVERT_TO_OBJECT:
/* @var $from OrchestrationRule */
static::targetToData($from, $to);
break;
case static::ACT_CONVERT_TO_ENTITY:
/* @var $to OrchestrationRule */
if (empty($from->target->targetType)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Missed target type");
}
static::targetToEntity($from, $to);
break;
case static::ACT_GET_FILTER_CRITERIA:
if (empty($from->target->targetType)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Missed target type");
}
if (!isset(static::$targetMap[$from->target->targetType])) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Unexpected target type!");
}
return [['target' => static::$targetMap[$from->target->targetType]]];
}
}