mirror of
https://github.com/Mibew/java.git
synced 2025-01-23 01:50:34 +03:00
Remove RequestProcessor::NO_RESULT_FUNCTION constant
RequestProcessor::NO_RESULT_FUNCTION not use any more. Rewrite code to throw use Mibew API checks for existance of the result function
This commit is contained in:
parent
1d4cac01d1
commit
24ecf02e7b
@ -131,29 +131,25 @@ abstract class RequestProcessor {
|
|||||||
// Try to load callback function for this token
|
// Try to load callback function for this token
|
||||||
$callback = $this->loadCallback($request['token']);
|
$callback = $this->loadCallback($request['token']);
|
||||||
|
|
||||||
// Try to get result function
|
if (! is_null($callback)) {
|
||||||
$result_function = $this->mibewAPI->getResultFunction($request['functions']);
|
// There is callback function. Try to get result arguments
|
||||||
|
$arguments = $this->processRequest($request, true);
|
||||||
// Callback exists but result function does not
|
$function = $callback['function'];
|
||||||
if (! is_null($callback) && is_null($result_function)) {
|
$arguments += empty($callback['arguments'])
|
||||||
throw new RequestProcessorException(
|
? array()
|
||||||
"There is no 'result' function in request",
|
: $callback['arguments'];
|
||||||
RequestProcessorException::NO_RESULT_FUNCTION
|
call_user_func_array($function, array($arguments));
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! is_null($result_function)) {
|
|
||||||
if (! is_null($callback)) {
|
|
||||||
// There are callback function and result function
|
|
||||||
$arguments = $this->processRequest($request, true);
|
|
||||||
$function = $callback['function'];
|
|
||||||
$arguments += empty($callback['arguments'])
|
|
||||||
? array()
|
|
||||||
: $callback['arguments'];
|
|
||||||
call_user_func_array($function, array($arguments));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
// Try to get result function
|
||||||
|
$result_function = $this->mibewAPI->getResultFunction($request['functions']);
|
||||||
|
|
||||||
|
if (! is_null($result_function)) {
|
||||||
|
// There is result function but no callback
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is no result function
|
||||||
// Process request
|
// Process request
|
||||||
$arguments = $this->processRequest($request, false);
|
$arguments = $this->processRequest($request, false);
|
||||||
// Send response
|
// Send response
|
||||||
@ -251,13 +247,6 @@ abstract class RequestProcessor {
|
|||||||
$result = $this->processRequest($request, true);
|
$result = $this->processRequest($request, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($result)) {
|
|
||||||
throw new RequestProcessorException(
|
|
||||||
"There is no 'result' function in response",
|
|
||||||
RequestProcessorException::NO_RESULT_FUNCTION
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// Trigger error event
|
// Trigger error event
|
||||||
$vars = array('exception' => $e);
|
$vars = array('exception' => $e);
|
||||||
@ -487,14 +476,10 @@ abstract class RequestProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class RequestProcessorException extends Exception {
|
class RequestProcessorException extends Exception {
|
||||||
/**
|
|
||||||
* Result function is absent
|
|
||||||
*/
|
|
||||||
const NO_RESULT_FUNCTION = 1;
|
|
||||||
/**
|
/**
|
||||||
* Wrong function arguments
|
* Wrong function arguments
|
||||||
*/
|
*/
|
||||||
const WRONG_ARGUMENTS = 2;
|
const WRONG_ARGUMENTS = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user