protected function _os($from, $to, $action)
{
if ($action == self::ACT_CONVERT_TO_OBJECT) {
$to->os = !empty($from->osId) ? ['id' => $from->osId] : null;
} else {
if ($action == self::ACT_CONVERT_TO_ENTITY) {
$osId = ApiController::getBareId($from, 'os');
if (empty($osId)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_STRUCTURE, "Missed property 'os.id'");
} else {
if (!(is_string($osId) && preg_match('/^' . Entity\Os::ID_REGEXP . '$/', $osId))) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid identifier of the OS");
}
}
$to->osId = $osId;
} else {
if ($action == self::ACT_GET_FILTER_CRITERIA) {
$osId = ApiController::getBareId($from, 'os');
if (!(is_string($osId) && preg_match('/^' . Entity\Os::ID_REGEXP . '$/', $osId))) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid identifier of the OS");
}
return [['osId' => $osId]];
}
}
}
}