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)) {
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 {
$to->osId = null;
}
} else {
if ($action == self::ACT_GET_FILTER_CRITERIA) {
if (empty($from->os) || !preg_match('/^' . Entity\Os::ID_REGEXP . '$/', $from->os)) {
throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Invalid identifier of the OS");
}
return [['osId' => $from->os]];
}
}
}
}