我正在尝试使用PHP SDK in camunda但是没有明确记录如何设置流程变量。
有什么想法吗?
答案 0 :(得分:2)
您可以使用ProcessInstanceService
。
以下是演示发票收据的摘要。
$camundaAPI = new \org\camunda\php\sdk\Api('http://localhost:8080/engine-rest');
$processDefinitionRequest = new \org\camunda\php\sdk\entity\request\ProcessDefinitionRequest();
$processDefinitions = $camundaAPI->processDefinition->getDefinitions($processDefinitionRequest);
foreach($processDefinitions AS $pd) {
echo 'Process deployment id: ' . $pd->getDeploymentId() . "\n";
}
// Process instance (make the assumption that $pd is the desired object).
$procInstance = $camundaAPI->processDefinition->startInstanceByKey($pd->getKey(), $processDefinitionRequest);
// ProcessInstanceService
$procInstanceService = new \org\camunda\php\sdk\service\ProcessInstanceService('http://localhost:8080/engine-rest/');
$var = new \org\camunda\php\sdk\entity\request\VariableRequest();
$var->setType('String');
$var->setValue('H4CK4THON2014');
$procInstanceService->putProcessVariable($procInstance->getId(), 'creditor', $var);