Through custom plugin you can call a PHP script and the result of the script (which is saved in the context variables) can then be used in the Gateway condition in the Process flow to execute the flow accordingly at run-time.
Here's an example of script whose result is saved in phpOutput and phpOutputError.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
BufferedReader input = null;
try {
// php file path
String scriptName = "Test.php";
// php parameters
String param = "params";
String line;
StringBuilder output = new StringBuilder();
Process p = Runtime.getRuntime().exec(
"php " + scriptName + " " + param);
input = new BufferedReader(
new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
output.append(line);
}
context.put("phpOutput", output);
} catch (Exception err) {
context.put("phpOutputError", err.getMessage());
err.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Comments
0 comments
Article is closed for comments.